Allow overriding the default 500 response on uncaught errors
Aperta
http
proposal
- Lingua principale
- TypeScript
- Stelle
- 38
- Fork
- 1
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
**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' } }]
}
})
```
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.