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:
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
err | Object | The error object. | ||
req | Object | Express request object. | ||
res | Object | Express response object. | ||
next | function | Express next function. |
See:
const app = express();
app.use(errorHandler);