Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
TE.mapLeft((e: Error & { status?: number; additional?: { headers?: Dictionary } }) => {
if (!reply.sent) {
const status = e.status || 500;
reply
.type('application/problem+json')
.serializer(JSON.stringify)
.code(status);
if (e.additional && e.additional.headers) {
reply.headers(e.additional.headers);
}
reply.send(ProblemJsonError.fromPlainError(e));
} else {
reply.res.end();
}
request.log.error({ input }, `Request terminated with error: ${e}`);
})
)();