Hello lads
I have added an Untill Success object into flow and I whenever there is an error, within On Error Continue object, I save the value of error object to a variable(error_object var), run few processes and then I would like to raise an error manually using the same error type and error message that I saved previously into a variable.
The problem is: the raise error component does not allow to use value from variables. It requires hard coded strings.
I would need something like #vars.error_object.errorType.
According to the documentation it is not possible.
Could anyone suggest a workaround for this?
Anurag Sharma (Nagarro) Forum Ambassador
Hello @Kleber Bueno​
In MuleSoft, the raise-error component does indeed require hard-coded values for the type and description
attributes, which can be limiting when you need to dynamically raise errors based on variable content. However, there's a workaround using the scripting capabilities of MuleSoft, specifically with DataWeave to achieve dynamic error handling.
It sounds like you are already capturing and storing the error details in a variable (error_object). Make sure that this variable contains all necessary information, such as errorType and errorMessage.
instead of raise component you can use dataweave runtime functions.
check this - DataWeave similar functions as the Raise component https://docs.mulesoft.com/dataweave/2.4/dw-runtime
https://docs.mulesoft.com/dataweave/2.4/dw-runtime-functions-fail
.