...inside the error handler for a Mule 4 application, I want to examine the response headers from a failed HTTP request. (in particular, I want to get the values in x-headers returned by a rate limiting policy.)
The problem is that when the Mule Event gets to the error handler scope, the attributes are no longer visible. #[attributes] returns null
In the past I remember doing something like:
#[error.muleMessage.typedAttributes.headers."x-ratelimit-reset]
When I try this today, I get an exception that indicates that "muleMessage" is scoped "private final"
What can we do to examine the remains of a failed HTTP request during execution of the error handler?
It turns out that the answer is within #[error.errorMessage]
In that structure, the attributes and the payload at the time of the error can be seen.
So the proper expression to examine that header would be:
#[error.errorMessage.attributes.headers."x-ratelimit-reset"]
Try it in your logger from the error handler and see what you get!