alloc / alloc/saus

Allow overriding the default 500 response on uncaught errors

Open
#66 0 comments 0 reactions 0 assignees View on GitHub
http proposal
Dominant language
TypeScript
Stars
38
Forks
1
PR merge metrics
No merged PRs in 30d

Description

**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).

```ts
interpretErrors((error, req) => {
if (req.method == 'post' && error.message == 'Unexpected end of JSON input') {
return [400, null, { json: { error: 'malformed-json' } }]
}
})
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.