How to use the serialize-error.serializeError function in serialize-error

To help you get started, we’ve selected a few serialize-error examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gajus / slonik / src / sqlFragmentFactories / createJsonSqlFragment.js View on Github external
if (token.value === undefined) {
    throw new InvalidInputError('JSON payload must not be undefined.');
  } else if (token.value === null) {
    value = token.value;

  // @todo Deep check Array.
  // eslint-disable-next-line no-negated-condition
  } else if (!isPlainObject(token.value) && !Array.isArray(token.value)) {
    throw new InvalidInputError('JSON payload must be a primitive value or a plain object.');
  } else {
    try {
      value = JSON.stringify(token.value);
    } catch (error) {
      log.error({
        error: serializeError(error),
      }, 'payload cannot be stringified');

      throw new InvalidInputError('JSON payload cannot be stringified.');
    }

    if (value === undefined) {
      throw new InvalidInputError('JSON payload cannot be stringified. The resulting value is undefined.');
    }
  }

  // Do not add `::json` as it will fail if an attempt is made to insert to jsonb-type column.
  return {
    sql: '$' + (greatestParameterPosition + 1),
    values: [
      value,
    ],
github teambit / bit / src / logger / logger.js View on Github external
function addBreakCrumb(category: string, message: string, data: Object = {}, extraData) {
  const hashedData = {};
  Object.keys(data).forEach(key => (hashedData[key] = Analytics.hashData(data[key])));
  const messageWithHashedData = format(message, hashedData);
  extraData = extraData instanceof Error ? serializeError(extraData) : extraData;
  Analytics.addBreadCrumb(category, messageWithHashedData, extraData);
}
github gajus / slonik / src / factories / createConnection.js View on Github external
}

  let connection: InternalDatabaseConnectionType;

  let remainingConnectionRetryLimit = clientConfiguration.connectionRetryLimit;

  while (true) {
    remainingConnectionRetryLimit--;

    try {
      connection = await pool.connect();

      break;
    } catch (error) {
      parentLog.error({
        error: serializeError(error),
        remainingConnectionRetryLimit,
      }, 'cannot establish connection');

      if (remainingConnectionRetryLimit > 1) {
        parentLog.info('retrying connection');

        continue;
      } else {
        throw new ConnectionError(error.message);
      }
    }
  }

  if (!connection) {
    throw new UnexpectedStateError('Connection handle is not present.');
  }
github sindresorhus / electron-better-ipc / source / main.js View on Github external
const listener = async (event, data) => {
		const browserWindow = BrowserWindow.fromWebContents(event.sender);

		const send = (channel, data) => {
			if (!(browserWindow && browserWindow.isDestroyed())) {
				event.sender.send(channel, data);
			}
		};

		const {dataChannel, errorChannel, userData} = data;

		try {
			send(dataChannel, await callback(userData, browserWindow));
		} catch (error) {
			send(errorChannel, serializeError(error));
		}
	};
github teambit / bit / src / logger / logger.ts View on Github external
function addBreadCrumb(category: string, message: string, data: Record = {}, extraData) {
  const hashedData = {};
  Object.keys(data).forEach(key => (hashedData[key] = Analytics.hashData(data[key])));
  const messageWithHashedData = format(message, hashedData);
  extraData = extraData instanceof Error ? serializeError(extraData) : extraData;
  Analytics.addBreadCrumb(category, messageWithHashedData, extraData);
}
github wikimedia / mediawiki-extensions-Wikibase / client / data-bridge / src / store / getters.ts View on Github external
		const serializedApplicationErrors = this.state.applicationErrors.map( ( error ) => serializeError( error ) );
		const stackTrace = JSON.stringify( serializedApplicationErrors, null, 4 );
github gajus / global-agent / src / classes / Agent.js View on Github external
request.on('error', (error) => {
      log.error({
        error: serializeError(error),
      }, 'request error');
    });
github fubhy / graphql-transport-electron / src / server.ts View on Github external
      error => event.sender.send(channel, id, 'error', serializeError(error)),
      () => event.sender.send(channel, id, 'complete'),

serialize-error

Serialize/deserialize an error into a plain object

MIT
Latest version published 1 year ago

Package Health Score

78 / 100
Full package analysis