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;
}
});
}))
function exitWithError(error) {
console.error(VError.fullStack(error)) // eslint-disable-line no-console
process.exit(1)
}
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)
}
})
}
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')
}
})
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));
}
});
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)
}
}
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;
}
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))
);
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;
}
};