Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mule 3到Mule 4错误处理查询错误类型和http状态_Mule_Anypoint Studio_Dataweave - Fatal编程技术网

Mule 3到Mule 4错误处理查询错误类型和http状态

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时,我可以将其视为变量,但当抛出错误时,它似乎消失了,并且无法在消息中找到它 在哪里可以找到错误处理类

我正在使用Anypoint Studio 7将错误处理文件从Mule 3迁移到Mule 4

我的问题是:

  • 由于在异常消息中看不到相同的信息,我现在如何执行此检查<代码>#[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种类型的错误处理程序

  • 论错误传播
  • 出错时继续
  • 试一试
  • 您可以在错误处理程序配置中查找并定义要捕获其错误的错误类型。

    要获取http状态代码,可以使用#[error.muleMessage.attributes.StatusCode]

    有关Mule 4错误处理的更多信息和更好的理解,请参阅:


    在Mule 4中,错误响应的http状态代码位于此处
    #[error.errorMessage.attributes['statusCode']]

    您能扩展您的答案以包括所有查询的答案吗?