如何提取Mulesoft JSON模式验证程序错误?

如何提取Mulesoft JSON模式验证程序错误?,json,mule,mule-component,json-schema-validator,Json,Mule,Mule Component,Json Schema Validator,在Mulesoft中使用“Validate JSON Schema”元素时,如果发生多个验证错误,则将以下消息放入#[异常] org.mule.api.MessagingException: Json content is not compliant with schema com.github.fge.jsonschema.core.report.ListProcessingReport: failure --- BEGIN MESSAGES --- error: string "blah"

在Mulesoft中使用“Validate JSON Schema”元素时,如果发生多个验证错误,则将以下消息放入#[异常]

org.mule.api.MessagingException: Json content is not compliant with schema
com.github.fge.jsonschema.core.report.ListProcessingReport: failure
--- BEGIN MESSAGES ---
error: string "blah" is too long (length: 4, maximum allowed: 3)
    level: "error"
    schema: {"loadingURI":"file:/...}
    instance: {"pointer":"/blah_blah_code"}
    domain: "validation"
    keyword: "maxLength"
    value: "blah"
    found: 4
    maxLength: 3
error: string "USDe" is too long (length: 4, maximum allowed: 3)
    level: "error"
    schema: {"loadingURI":"file:/..."}
    instance: {"pointer":"/blah_code"}
    domain: "validation"
    keyword: "maxLength"
    value: "USDe"
    found: 4
    maxLength: 3
---  END MESSAGES  ---

是否还有提取单个错误的方法?

您可以在捕获异常策略中使用when条件,并相应地为每个元素设置有效负载

下面是blah元素的示例

<when expression="#[exception.causedBy(org.mule.api.MessagingException)&amp;&amp; exception.cause.message.contains('schema') &amp;&amp; exception.cause.message.contains('blah')]">
  <set-payload value="include element specification here" doc:name="Json schema validation error"/>
</when>

您可以在catch异常策略中使用when条件,并相应地为每个元素设置有效负载

下面是blah元素的示例

<when expression="#[exception.causedBy(org.mule.api.MessagingException)&amp;&amp; exception.cause.message.contains('schema') &amp;&amp; exception.cause.message.contains('blah')]">
  <set-payload value="include element specification here" doc:name="Json schema validation error"/>
</when>