mule映射异常策略只适用于第一个401分支

mule映射异常策略只适用于第一个401分支,mule,mule-studio,Mule,Mule Studio,问这个问题需要一些mulesoft的专业知识 以下异常映射策略应该在hhtp.status 401、403、429上分支,但对于状态代码401和403(至少,由调试和写入控制台的日志确定),它会继续落入401分支: 这是因为它仅在异常类型org.mule.module.http.internal.request.ResponseValidatorException上进行分支吗?我以为这是为了转移身份代码 还有另一种策略,choice exception strategy,它应该在不同的异常对

问这个问题需要一些mulesoft的专业知识

以下异常映射策略应该在hhtp.status 401、403、429上分支,但对于状态代码401和403(至少,由调试和写入控制台的日志确定),它会继续落入401分支:


这是因为它仅在异常类型org.mule.module.http.internal.request.ResponseValidatorException上进行分支吗?我以为这是为了转移身份代码


还有另一种策略,choice exception strategy,它应该在不同的异常对象类型上分支。

APIkit根据定义的异常值而不是定义的状态码匹配异常。使用选择异常策略,并在其中定义多捕获异常策略。确保每个catch异常策略都匹配一个唯一的异常,以便为正确的http.status代码和所需的异常负载铺平道路


例如,如果希望抛出400,请确保catch异常策略与BadrequestException匹配。如果状态代码来自HTTP请求者,则匹配ResponseValidatoreException并设置传入的HTTP.status和异常负载

基于HTTP的异常分支。可以使用以下示例中的选择异常策略定义状态

<choice-exception-strategy doc:name="Choice Exception Strategy">
    <catch-exception-strategy  when="#[message.inboundProperties.'http.status'=='404']" doc:name="Catch Exception Strategy" >
    <logger message="Exceptions message is ... #[exception.message]" level="ERROR"  doc:name="exceptionLogger"/>
    <set-variable variableName="exceptionMessage" value="#[exception.message]" doc:name="Set exceptionMessage"/>
    <set-payload value="{  errors: {     errorCode: #[message.inboundProperties.'http.status'],     errorMessage: #[flowVars.exceptionMessage]  }  }" doc:name="Set Exception Payload"/>
</catch-exception-strategy>
<catch-exception-strategy  doc:name="Catch Exception Strategy" >
    <logger message="Exception message is ... #[exception.message]" level="ERROR" category="com.project.stacktrace" doc:name="exceptionLogger"/>
    <set-variable variableName="exceptionMessage" value="#[exception.message]" doc:name="Set exceptionMessage"/>
    <set-payload value="{  errors: {     errorCode: #[message.inboundProperties.'http.status'],     errorMessage: #[flowVars.exceptionMessage]  }  }" doc:name="Set Exception Payload"/>
</catch-exception-strategy>
    </choice-exception-strategy>


谢谢,这看起来很有希望;我会调查一下谢谢,我会调查一下这两个建议
<choice-exception-strategy doc:name="Choice Exception Strategy">
    <catch-exception-strategy  when="#[message.inboundProperties.'http.status'=='404']" doc:name="Catch Exception Strategy" >
    <logger message="Exceptions message is ... #[exception.message]" level="ERROR"  doc:name="exceptionLogger"/>
    <set-variable variableName="exceptionMessage" value="#[exception.message]" doc:name="Set exceptionMessage"/>
    <set-payload value="{  errors: {     errorCode: #[message.inboundProperties.'http.status'],     errorMessage: #[flowVars.exceptionMessage]  }  }" doc:name="Set Exception Payload"/>
</catch-exception-strategy>
<catch-exception-strategy  doc:name="Catch Exception Strategy" >
    <logger message="Exception message is ... #[exception.message]" level="ERROR" category="com.project.stacktrace" doc:name="exceptionLogger"/>
    <set-variable variableName="exceptionMessage" value="#[exception.message]" doc:name="Set exceptionMessage"/>
    <set-payload value="{  errors: {     errorCode: #[message.inboundProperties.'http.status'],     errorMessage: #[flowVars.exceptionMessage]  }  }" doc:name="Set Exception Payload"/>
</catch-exception-strategy>
    </choice-exception-strategy>