From 379c53175ce5a88e0d7f06bff153bc21e1018b0a Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Tue, 6 Dec 2022 12:47:08 +0800 Subject: [PATCH] Add note about how to handle errors --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index a8b7330..8988b22 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,10 @@ var err = new createError.NotFound() |510 |NotExtended | |511 |NetworkAuthenticationRequired| +## Handling the errors + +If used with Express, the [default error handler](https://expressjs.com/en/guide/error-handling.html) will handle errors created using `http-errors` and respond with an appropriate HTML response. If you are developing an API and need to send and handle JSON responses, you might want to create your own error handler, or use a module like [`error-handler-json`](https://github.com/mifi/error-handler-json) (based on the unmaintained [`api-error-handler`](https://github.com/expressjs/api-error-handler) project.) + ## License [MIT](LICENSE)