Skip to main content

errorHandler

function errorHandler(err: Object, req: Object, res: Object, next: function)

Logs the error stack and sends a JSON response with the error message and status code.
See the official express package documentation for more details:

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
errObjectThe error object.
reqObjectExpress request object.
resObjectExpress response object.
nextfunctionExpress next function.

See:

const app = express();
app.use(errorHandler);