Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}).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;
}
});
}))
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;
};
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;
}
};
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);
}
function onResponse(promptErr) {
if (promptErr) {
console.error('\nAborting.');
next(true);
} else {
var errLine = VError.info(parseErr).line;
if (errLine) {
editLine = errLine;
}
setImmediate(editAttempt);
}
}
);
.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 {
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 {
}
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");
}
}
}