Mule &引用;执行多捕获异常策略“;
我有选择异常策略,我有多重捕获异常策略,我根据错误应用条件 错误1: org.mule.api.MessagineException:“部门id”列不能为空(java.sql.SQLIntegrityConstraintViolationException) 错误2: org.mule.api.MessagineException:org.mule.module.db.internal.domain.connection.ConnectionCreationException:无法获取URL jdbc的连接:mysql://localhost:3306/mulesoft :拒绝访问用户“root1212”@“localhost”(使用密码:YES)(java.sql.SQLException)(org.mule.module.db.internal.processor.DbConnectionException) 如何在catch异常策略中使用表达式区分这两种错误 首次捕获-在以下情况下执行: [exception.causeMatches(“org.mule.api.messagingeexception:Column'department_id'不能为空*”) 第二次捕获-在以下情况下执行: [exception.causeMatches(“org.mule.api.MessaginException:org.mule.module.db.internal.domain.connection.ConnectionCreationException*”) 通过使用此策略,无法触发捕获异常策略 [异常.原因匹配(“org.mule.api.MessaginException*”)]Mule &引用;执行多捕获异常策略“;,mule,mule-studio,anypoint-studio,mule-esb,Mule,Mule Studio,Anypoint Studio,Mule Esb,我有选择异常策略,我有多重捕获异常策略,我根据错误应用条件 错误1: org.mule.api.MessagineException:“部门id”列不能为空(java.sql.SQLIntegrityConstraintViolationException) 错误2: org.mule.api.MessagineException:org.mule.module.db.internal.domain.connection.ConnectionCreationException:无法获取URL j
这是可行的,但对于两个错误,获取相同的起始字符串。如何区分两者?如果您想根据根本原因捕获特定异常。对具有完全限定异常名称的异常使用causedBy方法。下面的示例处理2个特定异常,然后处理所有其他异常的默认捕获
<choice-exception-strategy>
<catch-exception-strategy when="#[exception.causedBy(com.ricston.CustomException)">
<!-- do stuff -->
</catch-exception-strategy>
<catch-exception-strategy when="#[exception.causedBy(org.mule.module.db.internal.domain.connection.ConnectionCreationException)">
<!-- do stuff -->
</catch-exception-strategy>
<catch-exception-strategy>
<!-- other exceptions. do stuff -->
</catch-exception-strategy>
</choice-exception-strategy>