Mule 3到Mule 4错误处理查询错误类型和http状态
我正在使用Anypoint Studio 7将错误处理文件从Mule 3迁移到Mule 4 我的问题是:Mule 3到Mule 4错误处理查询错误类型和http状态,mule,anypoint-studio,dataweave,Mule,Anypoint Studio,Dataweave,我正在使用Anypoint Studio 7将错误处理文件从Mule 3迁移到Mule 4 我的问题是: 由于在异常消息中看不到相同的信息,我现在如何执行此检查#[exception.causedBy(org.mule.module.http.internal.request.ResponseValidatorException)]” 现在在哪里可以找到http.status属性?当它为200时,我可以将其视为变量,但当抛出错误时,它似乎消失了,并且无法在消息中找到它 在哪里可以找到错误处理类
- 由于在异常消息中看不到相同的信息,我现在如何执行此检查<代码>#[exception.causedBy(org.mule.module.http.internal.request.ResponseValidatorException)]”
- 现在在哪里可以找到http.status属性?当它为200时,我可以将其视为变量,但当抛出错误时,它似乎消失了,并且无法在消息中找到它
- 在哪里可以找到错误处理类型的列表
HTTP:BAD_REQUEST
HTTP:UNAUTHORIZED
HTTP:FORBIDDEN
HTTP:RESOURCE_NOT_FOUND
HTTP:METHOD_NOT_ALLOWED
HTTP:NOT_ACCEPTABLE
HTTP:CONFLICT
HTTP:UNSUPPORTED_MEDIA_TYPE
HTTP:INTERNAL_SERVER_ERROR
HTTP:BAD_GATEWAY
下面是我正在迁移的Mule 3代码片段,我认为它基于一个模板:
<choice-exception-strategy name="global-exception-strategy">
<catch-exception-strategy when="#[exception.causedBy(org.mule.module.http.internal.request.ResponseValidatorException)]" doc:name="Caused By (org.mule.module.http.internal.request.ResponseValidatorException)">
<choice doc:name="Choice">
<when expression="#[message.inboundProperties['http.status'] == 401]">
<set-variable variableName="errorMessage" value="Upstream service did not authorize the request." doc:name="Set Error Message"/>
<flow-ref name="global-bad-gateway-response-sub-flow" doc:name="Bad Gateway Response"/>
</when>
<otherwise>
<set-variable variableName="errorMessage" value="Upstream service internal error." doc:name="Set Error Message"/>
<flow-ref name="global-bad-gateway-response-sub-flow" doc:name="Bad Gateway Response"/>
</otherwise>
</choice>
</catch-exception-strategy>
</choice-exception-strategy>
<sub-flow name="global-bad-gateway-response-sub-flow">
<set-property propertyName="http.status" value="401" doc:name="Set Status"/>
<set-payload value="UNAUTHORIZED" doc:name="Set Error Code" mimeType="application/java"/>
<flow-ref name="global-prepare-error-response-sub-flow" doc:name="Prepare Error Response"/>
</sub-flow>
谢谢你使用这种支票
#[contains(error.description,'internal server error (500).')]
Hi Mule 4有3种类型的错误处理程序
在Mule 4中,错误响应的http状态代码位于此处
#[error.errorMessage.attributes['statusCode']]您能扩展您的答案以包括所有查询的答案吗?