【问题标题】:Throw custom exception from catch-exception-strategy从 catch-exception-strategy 抛出自定义异常
【发布时间】:2015-01-17 20:56:48
【问题描述】:

是否可以从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

谁能解决这个问题?提前致谢。

【问题讨论】:

    标签: java exception-handling mule


    【解决方案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 之外尝试...

    【讨论】:

    • 我知道,如果我将脚本组件放在catch-exception-strategy 之外,它就可以正常工作。我真正需要的是在catch-exception-strategy 中捕获异常时,我只需要包装原因并重新抛出我的自定义异常。有可能吗?
    • 确实这似乎是不可能的。我不认为上面是这个问题的解决方案。
    • 这个答案不包括重新抛出异常。
    猜你喜欢
    • 2020-01-10
    • 2011-10-06
    • 1970-01-01
    • 2011-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-08
    相关资源
    最近更新 更多