Error

Methods

(inner) Handle(error, response)

All the errors thrown by the application code, in any of the modules, are routed through this method.

Upon receiving an error, the method first runs an identity check.

  • If the error is of type ClientError, it sends an error response with one of the 4xx status codes.
  • If the error is of type ExternalError, it sends an error response with a 424 Failed Dependency status code.
  • If the error is of any other type, it's assumed to an internal server error and a 500 Internal Server Error response is sent.

Regardless of the error type, each response includes a detailed description, help message and debugging information in the response body.

Parameters:
Name Type Description
error Error

The error thrown

response Express.Response

The response object that will be used to communicate the error back to the client

Source: