DataWeave 中访问抛出的异常

Access thrown exception in DataWeave

是否可以在Catch Exception Strategy -> Transform Message组件中访问异常?我知道我可以通过 MEL #[exception.cause] 访问它,但我无法找到有关如何在 DataWeave 中访问它的任何信息。

非常感谢。

@Lukas,如果您通过流引用捕获异常,那么调用流将能够使用 dataweave 评估异常。在 Catch Exception Strategy 中,尝试将异常设置为有效载荷,然后在调用流程中,dataweave 将处理该异常。

你可以在 payload 中设置异常(就像 @Ralph Rimorin 建议的那样)或者你可以将它设置为变量并在 dw 中使用 -

<catch-exception-strategy doc:name="Catch Exception Strategy">
        <logger message="#[exception.message]" level="ERROR" doc:name="Logger"></logger>
        <set-variable variableName="exception" value="#[exception]"
            doc:name="Set Exception to FlowVars"
            doc:description="This is to ensure that exception object is avaiable to Send Support Email component which uses exception from flowVars instead of the one set by mule at #[exception] as it sometimes tend to get lost."></set-variable>
        <dw:transform-message doc:name="Transform Message">
            <dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
{
a:flowVars.exception
}]]></dw:set-payload>
        </dw:transform-message>


    </catch-exception-strategy>