veejay
veejay

Reputation: 115

Could not able to get element XML in Mule 4.2.2

I am trying to access error.exception.info['Element'] in Mule 4 error object. It works fine if i raise an error manually using Raise error Component like below. `

<choice doc:name="Choice" doc:id="c149e906-9c84-45dd-9d11-3be58e9f2d03">
            <when
                expression='#[!(some expression)]'>
                <set-variable
                    value="#['Invalid Type found for the target operation']"
                    doc:name="Error Message" doc:id="ebc156a9-7aed-4cf9-ade5-d33f382fe5b7"
                    variableName="errorMessage" />
                <raise-error doc:name="Raise error"
                    doc:id="3511b08c-9e56-4d04-aee1-d5d0b8f87670" type="MY_APP:INVALID_TYPE"
                    description="#[vars.errorMessage]" />
            </when>

`

But If i try to do the same inside HTTP connector like below am not getting `

<http:request method="POST" doc:name="Call Audit Endpoint" doc:id="e2a39da6-e6e3-4c33-9e6f-41d24de4d23b" config-ref="Request_Configuration" path="${http.request.path}${http.request.path.auditlog}" target="auditLog">
            <error-mapping targetType="APP:TEST" />
        </http:request>

error.exception.info['Element']` as like above. basically I need to access error.exception.info['Element'] and error.exception.info['Element XML'] details incase of any error. Any work around or suggestions would be helpful. Thanks!

Upvotes: 0

Views: 207

Answers (1)

Alex
Alex

Reputation: 4473

Every exception is unique. That's why it is called exception. One, what you had raised manually, does have this attribute but targetType="APP:TEST" does not have it.

Don't expect excption to be ordinary and have attribute what you expect. Some exceptions have zero attributes. Debugger or Logger('#[error]') could help. But not always. Dig down on every exception what you have and make it not exceptional - catch it and process properly.

Upvotes: 1

Related Questions