How to use verror - 10 common examples

To help you get started, we’ve selected a few verror 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 pmarkert / hyperpotamus / test / index.js View on Github external
}).catch(err => {
					if (!should_expect_failure) {
						// eslint-disable-next-line no-console
						var info = verror.info(err);
						// eslint-disable-next-line no-console
						console.log("Error metadata:\n" + yaml.dump(err));
						throw err;
					}
				});
		}))
github cucumber / cucumber-js / src / cli / run.js View on Github external
function exitWithError(error) {
  console.error(VError.fullStack(error)) // eslint-disable-line no-console
  process.exit(1)
}
github cucumber / cucumber-js / src / runtime / parallel / slave.js View on Github external
await Promise.each(this.supportCodeLibrary[key], async hookDefinition => {
      const { error } = await UserCodeRunner.run({
        argsArray: [],
        fn: hookDefinition.code,
        thisArg: null,
        timeoutInMilliseconds:
          hookDefinition.options.timeout ||
          this.supportCodeLibrary.defaultTimeout,
      })
      if (error) {
        const location = formatLocation(hookDefinition)
        console.error(
          VError.fullStack(
            new VError(
              error,
              `${name} hook errored on slave ${this.id}, process exiting: ${location}`
            )
          )
        ) // eslint-disable-line no-console
        this.exit(1)
      }
    })
  }
github dtinth / automatron / app.js View on Github external
const getSecrets = cached('secret', async () => {
  try {
    // via http://gunargessner.com/gcloud-env-vars/
    const [contents] = await gcs
      .bucket(bucketName)
      .file('secrets.env')
      .download()
    const secrets = dotenv.parse(contents)
    console.log('Secrets loaded with keys', Object.keys(secrets))
    return secrets
  } catch (error) {
    throw new VError(error, 'getSecrets() failed')
  }
})
github thredup / rollbar-sourcemap-webpack-plugin / src / RollbarSourceMapPlugin.js View on Github external
if (!this.silent) {
          console.info(`Uploaded ${sourceMap} to Rollbar`); // eslint-disable-line no-console
        }
        return cb();
      }

      const errMessage = `failed to upload ${sourceMap} to Rollbar`;
      if (err) {
        return cb(new VError(err, errMessage));
      }

      try {
        const { message } = JSON.parse(body);
        return cb(new Error(message ? `${errMessage}: ${message}` : errMessage));
      } catch (parseErr) {
        return cb(new VError(parseErr, errMessage));
      }
    });
github serafin-labs / serafin / src / serafin / api / transport / rest / Rest.ts View on Github external
public handleError(error, res: express.Response, next: (err?: any) => void) {
        // handle known errors
        if (![[ValidationErrorName, 400], [NotFoundErrorName, 404], [ConflictErrorName, 409], [NotImplementedErrorName, 405], [UnauthorizedErrorName, 401]].some((p: [string, number]) => {
            let [errorName, code] = p;
            if (VError.findCauseByName(error, errorName)) {
                res.status(code).json({
                    code: code,
                    message: error.message
                })
                return true
            }
            return false
        })) {
            // or pass the error down the chain
            console.error(VError.fullStack(error));
            next(error)
        }
    }
github openkfw / TruBudget / api / src / service / domain / workflow / subproject_assigned.ts View on Github external
export function mutate(subproject: Subproject.Subproject, event: Event): Result.Type {
  if (event.type !== "subproject_assigned") {
    throw new VError(`illegal event type: ${event.type}`);
  }

  // Since we cannot have any side effects here, the existance of a user is expected to
  // be validated before the event is produced.
  subproject.assignee = event.assignee;
}
github hugo-cardenas / lickit / src / state / actions / lick / lick.js View on Github external
return async (dispatch, getState) => {
            const storedTracks = getStoredTracks(getState(), lick.id);
            let tracks;

            try {
                // Handle all new tracks submitted in form
                tracks = await Promise.all(
                    lick.tracks.map(track => handleTrack(track))
                );
            } catch (error) {
                throw new VError(
                    error,
                    'Unable to create action %s with lick %s',
                    LICK_UPDATE,
                    JSON.stringify(lick)
                );
            }

            try {
                // Delete all stored tracks which haven't been submitted
                const ids = tracks.map(track => track.id);
                const toBeDeletedTracks = storedTracks.filter(
                    track => !ids.includes(track.id)
                );
                await Promise.all(
                    toBeDeletedTracks.map(track => deleteTrack(track.id))
                );
github coralproject / talk / src / core / server / logger / serializers.ts View on Github external
if (err instanceof GraphQLError && err.originalError) {
    // If the error was caused by another error, integrate it.
    obj.originalError = errSerializer(err.originalError);
  } else if (err instanceof CoralError) {
    // Copy over the CoralError specific details.
    obj.id = err.id;
    obj.context = err.context;

    // If the error was caused by another error, integrate it.
    const cause = err.cause();
    if (cause) {
      obj.originalError = errSerializer(cause);
    }
  } else if (err instanceof VError) {
    obj.context = VError.info(err);
  }

  return obj;
};
github pmarkert / hyperpotamus / lib / normalize.js View on Github external
if (_.isArray(action)) {
			// And now normalize actions
			return action.map(actionNormalizer);
		}
		for (var j = 0; j < normalizingPlugins.length; j++) {
			try {
				var result = normalizingPlugins[j].normalize(action, actionNormalizer, path);
				if (result) {
					action = result;
				}
			}
			catch (err) {
				throw new verror.VError({
					name: "ActionNormalizationError",
					cause: err,
					info: _.defaults(verror.info(err), {
						action,
						path
					})
				}, "action normalization failure");
			}
		}
		action.path = path;
		if (action.on_failure) {
			action.on_failure = actionNormalizer(action.on_failure, "on_failure");
		}
		if (action.on_success) {
			action.on_success = actionNormalizer(action.on_success, "on_success");
		}
		return action;
	}
};