"Executed multiple catch exception strategy "
"Executed multiple catch exception strategy "
我有选择异常策略,我有多个捕获异常策略,我正在根据错误应用条件。
错误 1:
org.mule.api.MessagingException: Column 'department_id' cannot be null (java.sql.SQLIntegrityConstraintViolationException).
错误 2:
org.mule.api.MessagingException: org.mule.module.db.internal.domain.connection.ConnectionCreationException: Cannot get connection for URL jdbc:mysql://localhost:3306/mulesoft : Access denied for user 'root1212'@'localhost' (using password: YES) (java.sql.SQLException) (org.mule.module.db.internal.processor.DbConnectionException).
如何区分在 catch 异常策略中使用表达式的两种错误?
第一次捕获 - 执行时间:
[exception.causeMatches("org.mule.api.MessagingException: Column 'department_id' cannot be null*")]
第二个捕获 - 执行时间:
[exception.causeMatches("org.mule.api.MessagingException: org.mule.module.db.internal.domain.connection.ConnectionCreationException*")]
通过使用此无法触发捕获异常策略。
[exception.causeMatches("org.mule.api.MessagingException*")]
这是有效的,但对于获取相同起始字符串的错误。我怎样才能区分两者?
如果你想根据根本原因捕获特定的异常。使用完全限定的异常名称对异常使用 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>
我有选择异常策略,我有多个捕获异常策略,我正在根据错误应用条件。
错误 1:
org.mule.api.MessagingException: Column 'department_id' cannot be null (java.sql.SQLIntegrityConstraintViolationException).
错误 2:
org.mule.api.MessagingException: org.mule.module.db.internal.domain.connection.ConnectionCreationException: Cannot get connection for URL jdbc:mysql://localhost:3306/mulesoft : Access denied for user 'root1212'@'localhost' (using password: YES) (java.sql.SQLException) (org.mule.module.db.internal.processor.DbConnectionException).
如何区分在 catch 异常策略中使用表达式的两种错误?
第一次捕获 - 执行时间:
[exception.causeMatches("org.mule.api.MessagingException: Column 'department_id' cannot be null*")]
第二个捕获 - 执行时间:
[exception.causeMatches("org.mule.api.MessagingException: org.mule.module.db.internal.domain.connection.ConnectionCreationException*")]
通过使用此无法触发捕获异常策略。
[exception.causeMatches("org.mule.api.MessagingException*")]
这是有效的,但对于获取相同起始字符串的错误。我怎样才能区分两者?
如果你想根据根本原因捕获特定的异常。使用完全限定的异常名称对异常使用 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>