Allow overriding the default 500 response on uncaught errors
Ouverte
http
proposal
- Langage dominant
- TypeScript
- Étoiles
- 38
- Forks
- 1
- Métriques de merge des PR
- Aucune PR mergée en 30 j
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' } }]
}
})
```
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Évaluation
Cette issue n'a pas encore été évaluée.