处理错误部分中的对象 [英] Handling object in On-error Section

查看:72
本文介绍了处理错误部分中的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Team, 


在处理我们的后端服务之前,我们正在执行验证,如果验证失败,我们会发送400 Bad Request。 


有没有办法将下一步转发到错误部分,这样我将保存errorObject并添加一个自定义日志,显示验证错误。


PS :目前我正在使用Return Response,因此它会直接发送响应,而不执行任何进一步的步骤。如果我将errorObject存储在上下文变量中,那将在后端部分引发错误(这不应该发生)

解决方案

更新:我可以确认没有特定的政策,例如
但是有一种可以使用的解决方法。


只需要
`check-header`
策略用于不存在的头,它将执行发送到`on-error`范围。您可以在此策略之前在上下文变量中设置自定义错误对象,稍后您可以在"on-error"部分中访问该文档。

< check-header name =" dont-exist"失败检查-httpcode = QUOT; 400" failed-check-error-message =" Bad Request"忽略大小写= QUOT;真" /> 

---


AFAIK今天没办法做到这一点,但我会在内部证实这一点可以肯定。


`return-response`政策是我相信的唯一方法。


Hello Team, 

Before processing our service to backend we are performing validation and if the validation fails we are sending 400 Bad Request. 

is there any way to forward the next step to on error section, so that i will hold errorObject and add a custom log of whats the validation error.

P.S: Currently i am using Return Response, so it directly sends response back with out performing any further steps. If at all i store the errorObject in a context variable, that will raise an error in Backend section(this is not supposed to happen)

解决方案

UPDATE: I can confirm that there is no specific policy as such but there is a workaround that you can use.

Simply have a `check-header` policy for a non-existent header which will send execution into the `on-error` scope. You would set your custom error object in a context variable before this policy which you can access later in the `on-error` section.

<check-header name="dont-exist" failed-check-httpcode="400" failed-check-error-message="Bad Request" ignore-case="true" />

---

AFAIK there isn't a way to do this as of today but I will confirm this internally to be sure.

The `return-response` policy is the only way to go I believe.




这篇关于处理错误部分中的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆