alloc / alloc/saus

Allow overriding the default 500 response on uncaught errors

Đang mở
#66 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
http proposal
Ngôn ngữ chính
TypeScript
Star
38
Fork
1
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

**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' } }]
}
})
```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.