Search code examples
muledataweavemulesoft

What's the difference between error.errorMessage and error.muleMessage?


I am trying to understand the mule error object and I am a bit confused with what I see in the debugger.

Say there is a http request call failure in my app and in the debugger I can see the error object with muleMessage property.

And if I right click on error object > copy value then I don't see muleMessage in there. There it's called errorMessage. Both holds the same value.

Similarly, for IBM MQ listener. When I look at attributes in the debugger I can see attributes.headers.messageId. Yet, when I capture it in munits using munit recording, the same value is captured in attributes.headers.JMSMessageID in JSON.

Which ones should I be using?


Solution

  • In addition to what @Aled described.

    These are very important exprssons in Mule error handling and both works differently.

    The Mule error object is used to get information about errors in detail. The important expression in a mule error object are mainly these two -- error.errorMessage and error.description. These expressons are part of the public API and are guaranteed to be stable across all the Mule versions.

    error.description: Provides a clear detailed description of the error occured.

    error.errorMessage: it gives us additional details about the error if available.

    It's important that when you debug your application in debugger mode, the debugger might show other expressions like muleMessage, but those are not officially documented. These internal attributes may change without any notice in future Mule releases, so that will cause your application to fail if it relies on them.

    For JMS-related attributes, JMSMessageID is the standardized name according to JMS specifications and is likely the more reliable choice in your implementations.

    Related official document- https://docs.mulesoft.com/mule-runtime/latest/mule-error-concept#selector_expressions https://docs.mulesoft.com/mule-runtime/latest/mule-error-concept