How to print payload for exception in mule message flow

I have a mule stream inside which I register all the payload in String format, following the code snippet

<logger level="ERROR" message="#[payload:java.lang.String]"/>

Now, if an error occurs, there really is no need to print the entire payload. The payload object in the message is zero, and the exception payload is populated with the corresponding exception in it.

If I can only print the exception payload in String format, that would be enough. Does anyone know how to register the exception payload from a message?

+5
source share
4 answers
    <logger level="ERROR" message=" 
#[groovy:message.getExceptionPayload().getRootException().getMessage()]" /> 

The above code retrieves a message related to the reason for the exception.

+8

:

<logger level="ERROR" message="#[exception]"/>
+3

:

[groovy:message.getExceptionPayload().getRootException().getMessage()]
+1

If you want to save the error to the payload, you need to convert it:

%dw 2.0
output application/json
---
{
    error: error.detailedDescription,
    errorType: (error.errorType.namespace default '') ++ ":" ++ (error.errorType.identifier default '') ,
    recoverable: false
}

So, in the payload you have an error

0
source

Source: https://habr.com/ru/post/1525682/


All Articles