express-async-errors icon indicating copy to clipboard operation
express-async-errors copied to clipboard

Library usage and examples

Open brunolnetto opened this issue 2 years ago • 1 comments

Hi,

I was surfing around the internet looking to a good request error-handler for my Express app. Your library popped up like a charm. I know about Merror, which seemed to me well-documented enough to make me more interested on it rather than yours.

I am not myself a web-developer, which means I am interested to make things easy. I was unable to understand how to import/require or even understand how the library operates underneath in the sense to transform the caught error into something consumable. May you explain it?

brunolnetto avatar Feb 17 '23 13:02 brunolnetto

You have to import the library in your entry point/main file (before you import your routes) like so:

const express = require('express') require('express-async-errors') const app = express() etc...

Because of the library, you do not need the next(exception) call anymore. It handles everything under the hood.

JVPH avatar Aug 11 '23 00:08 JVPH