Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
reject(
@inject(RestBindings.Http.CONTEXT) {request, response}: HandlerContext,
error: Error,
) {
const err = error as HttpError;
if (!err.status && !err.statusCode && err.code) {
const customStatus = codeToStatusCodeMap[err.code];
if (customStatus) {
err.statusCode = customStatus;
}
}
const statusCode = err.statusCode || err.status || 500;
writeErrorToResponse(err, request, response, this.errorWriterOptions);
this.logError(err, statusCode, request);
}