What is Error Handling in Mulesoft In this article, we are going to discuss components of Mule error, Error types, categories of Mule error and components for handling Mule errors.
Components of Mule Error:
The Mule error is the result of the failure of the Mule exception to
the following components: • Description: This is an important component of the Mule error which will give a description of the problem. Its expression is as follows - #[error.description] • Type: The Mule Error “Type component” is used to characterize the problem. It also allows routing in an error handler. The expression is as follows- #[error.errorType] • Cause: The “Cause component” of the Mule error gives the underlying java disposable that is causing the failure. Its expression is as follows- #[error.cause] • Message: The Mule Error Message component displays an optional error message. Its expression is as follows- #[error.errorMessage] • Child Errors: The Child Errors component of the Mule error provides an optional collection of inner errors. These inner errors are mainly employed by elements like Scatter-Gather to supply aggregated route errors. Its expression is as follows - #[error.childErrors]
Example: If an HTTP request with status code 401 fails, the Mule errors are as follows Description: HTTP GET on resource ‘http://localhost:8181/TestApp’ failed: unauthorized (401) Type: HTTP:UNAUTHORIZED Cause: a ResponseValidatorTypedException instance Error Message: { "message" : "Could not authorize the user." }
Error Types: Let us understand the Error Types with the assistance of its characteristics – • The first characteristic of Mule Error Types is that it consists of both, a namespace and an identifier. this enables us to differentiate the kinds consistent with their domain. within the above example, the Error Type is HTTP: UNAUTHORIZED. • The second important characteristic is that the type of error can have a parent type. for instance, the Error Type HTTP: UNAUTHORIZED has MULE: CLIENT_SECURITY because the parent which successively also features a parent named MULE: SECURITY. This characteristic establishes the Error Type because of the specification of the more global items.
Kinds of Error Types: Following are the categories under which all the errors fall Any: The errors under this category are the errors that will occur during a Flow. They are not so severe and may be handled easily. Critical: The errors under this category are the severe errors that can't be handled. Following is that the list of Error Types under this category • Overload: This Error Type indicates an error occurred due to the problem of overloading. In this case, the execution will be rejected. • FATAL_JVM_ERROR: This kind of Error Type indicates the occurrence of a fatal error. for instance, stack overflow.