2015-01-17 136 views
3

是否有可能從catch-exception-strategy或任何其他異常策略中拋出自己的自定義異常。從捕捉異常策略中拋出自定義異常

我試圖象下面這樣:

<catch-exception-strategy doc:name="Catch Exception Strategy"> 
    <scripting:component doc:name="throw-custom-exception"> 
    <scripting:script engine="Groovy"> 
     <![CDATA[throw new org.mycompany.mule.CustomException()]]> 
    </scripting:script> 
    </scripting:component> 
</catch-exception-strategy> 

,但最終出現錯誤:

org.mule.exception.CatchMessagingExceptionStrategy: Failed to dispatch message to error queue after it failed to process

誰能解決這個問題?提前致謝。

回答

1

嘗試把

<scripting:component doc:name="throw-custom-exception"> 
    <scripting:script engine="Groovy"> 
     <![CDATA[throw new org.mycompany.mule.CustomException()]]> 
    </scripting:script> 
    </scripting:component> 

catch-exception-strategy和嘗試...

+2

我知道,它工作正常,如果我把腳本組件外'追趕異常strategy'。我真正需要的是捕獲catch-exception-strategy內的異常,我只需要包裝原因並重新拋出我的自定義異常。可能嗎? –

+0

確實這似乎是不可能的。我不認爲上面是這個問題的解決方案。 –

+0

此答案不包括重新拋出異常。 – Yuri