Proposal: Add a runtime hook (something like interpretErrors) that adds a handler that runs when an endpoint throws an error. The handler can return a ResponseTuple array or undefined (call next handler or send a 500 response).
interpretErrors((error, req) => {
if (req.method == 'post' && error.message == 'Unexpected end of JSON input') {
return [400, null, { json: { error: 'malformed-json' } }]
}
})
Proposal: Add a runtime hook (something like
interpretErrors
) that adds a handler that runs when an endpoint throws an error. The handler can return aResponseTuple
array or undefined (call next handler or send a 500 response).