“执行多重捕获异常策略”

时间:2019-05-08 08:52:42

标签: mule mule-studio mule-component anypoint-studio

我有选择异常策略,在这里我有多个捕获异常策略,我根据错误应用条件。 错误1:

org.mule.api.MessagingException:列'department_id'不能为空(java.sql.SQLIntegrityConstraintViolationException)。

错误2:

org.mule.api.MessagingException:org.mule.module.db.internal.domain.connection.ConnectionCreationException:无法获得URL的连接jdbc:mysql:// localhost:3306 / mulesoft:用户'root1212的访问被拒绝'@'localhost'(使用密码:是)(java.sql.SQLException)(org.mule.module.db.internal.processor.DbConnectionException)。

如何在catch异常策略中使用表达式来区分这两种错误?

第一次捕获-在以下情况下执行:

[exception.causeMatches(“ org.mule.api.MessagingException:列'department_id'不能为空*”)]

第二个捕获-在以下情况下执行:

[exception.causeMatches(“ org.mule.api.MessagingException:org.mule.module.db.internal.domain.connection.ConnectionCreationException *”)]

使用此方法无法触发捕获异常策略。

[exception.causeMatches(“ org.mule.api.MessagingException *”)] 这是可行的,但对于两个错误都使用相同的起始字符串。我该如何区分两者?

0 个答案:

没有答案