Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function buildErrorResponse(error: Error): Response {
let httpError: HttpError;
if (error instanceof HttpError) {
httpError = error;
} else {
httpError = new ServiceUnavailable('Upstream service is unavailable')
}
return {
statusCode: httpError.statusCode,
headers: DEFAULT_HEADERS,
body: JSON.stringify({
status: httpError.name,
statusCode: httpError.statusCode,
message: httpError.message
})
};
};
serviceUnavailable: function serviceUnavailable (message) {
return new createError.ServiceUnavailable(message)
},