alloc / alloc/saus

Allow overriding the default 500 response on uncaught errors

Aperta
#66 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
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.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.