How to use the verror.info function in verror

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 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;
	}
};
github pmarkert / hyperpotamus / hyperpotamus.js View on Github external
function dumpError(message, err) {
	var cause = findCause(err);
	var dump = {
		name: cause.name,
		message: cause.message
	};
	var path = findDeepestInfoProperty(err, "path");
	if(!_.isNil(path)) {
		dump.path = path;
	}
	dump.help_link = `https://github.com/pmarkert/hyperpotamus/wiki/errors#${cause.name}`;
	logger.debug(`Error stack-trace:\n${verror.fullStack(err)}`);
	logger.info(`Error details:\n${yaml.dump(verror.info(err), { lineWidth: process.stdout.columns, skipInvalid: true })}`);
	logger.error(`Error occurred while ${message}:\n${yaml.dump(dump, { lineWidth: process.stdout.columns, skipInvalid: true })}`);
	process.exit(1);
}
github trentm / jirash / lib / cli / do_issue / do_create.js View on Github external
function onResponse(promptErr) {
                            if (promptErr) {
                                console.error('\nAborting.');
                                next(true);
                            } else {
                                var errLine = VError.info(parseErr).line;
                                if (errLine) {
                                    editLine = errLine;
                                }
                                setImmediate(editAttempt);
                            }
                        }
                    );
github buttercup / buttercup-browser-extension / source / setup / containers / SaveCredentialsPage.js View on Github external
.catch(err => {
                            dispatch(unsetBusy());
                            const { authFailure = false } = VError.info(err);
                            if (authFailure) {
                                notifyWarning(
                                    "Authorisation failed",
                                    "The credentials were invalid - re-authenticating"
                                );
                            } else {
                                notifyError("Failed saving credentials", err.message);
                            }
                            console.error(err);
                        });
                } else {
github jamesplease / api-pls / packages / api-pls-cli / commands / sync.js View on Github external
if (!fs.existsSync(resourcesDir)) {
      log.error('The resource directory specified does not exist.');
      log.debug(`Searched for resources in: "${path.resolve(resourcesDir)}"`);

      if (log.level !== 'trace') {
        log.error('Run this command with --verbose to see more information about this error.');
      }
      return;
    }

    let migrationStrings;
    try {
      migrationStrings = sync.build(resourcesDir);
    } catch (e) {
      if (e.name === 'YAMLParseError') {
        const info = VError.info(e);
        log.error(`Building the migrations failed: Could not parse "${info.filename}" as YAML.`);
      } else if (e.name === 'JSONParseError') {
        const info = VError.info(e);
        log.error(`Building the migrations failed: Could not parse "${info.filename}" as JSON.`);
      } else if (e.name === 'DependencyGraphError') {
        if (_.startsWith(e.message, ': Dependency Cycle Found:')) {
          const rest = _.replace(e.message, ': Dependency Cycle Found: ', '');
          log.error(`Building the migrations failed, because a circular dependency was found: ${rest}.`);
          log.error('This is often caused by defining a relationship in two Resource Models, rather than one.');
          log.error('For more on setting up relationships, see the documentation: https://github.com/jmeas/api-pls/wiki/Relationships');
        } else if (_.startsWith(e.message, ': Node does not exist:')) {
          const rest = _.replace(e.message, ': Node does not exist: ', '');
          log.error(`Building the migrations failed, a Resource Model could not be found: "${rest}".`);
          log.error('This may be a bug in api-pls. Please file an issue at:');
          log.error('https://github.com/jmeas/api-pls/issues/new?title=Building+migrations:+my+resource+model+could+not+be+found');
        } else {
github pmarkert / hyperpotamus / lib / processor.js View on Github external
}
				else {
					throw new verror.VError({
						name: "InvalidPluginError",
						info: {
							plugin: plugin.name,
							path: action.path
						}
					}, "Unexpected number of arguments for plugin.process() method. (Must be 1 or 2 arguments)");
				}
			}
			catch (err) {
				throw new verror.VError({
					name: "ActionProcessingError",
					cause: err,
					info: _.defaults(verror.info(err), {
						action: action,
						path: action.path
					})
				}, "unexpected error occurred during action processing");
			}
		}
	}