gpt4 book ai didi

error-handling - 顶点 : How to get fail() status code in failure handler?

转载 作者:行者123 更新时间:2023-12-01 10:34:43 25 4
gpt4 key购买 nike

状态码如何传递给RoutingContext.fail(int)在失败处理程序中检索(使用 Route.failureHandler 注册)?

例如如果某些路由的处理时间过长,它可能会被 TimeoutHandlerRoutingContext 上调用 fail(408) 中断。 fail 方法随后调用失败处理程序(如果已注册)。但是我找不到任何方法(除了反射和取决于实现)如何在处理程序本身中找出它被调用的原因:

  • RoutingContext.failure() 返回 null
  • 状态码似乎只设置在 RoutingContextImpl 的私有(private)字段中,尚未设置在 HttpServerResponse

最佳答案

不确定 Vert.x 的旧版本,但从 3.0.0 开始:

eventBus.send("some.address", "some value", event -> {
if (event.succeeded()) {
System.out.println("Received reply: " + event.result().body());
} else {
ReplyException cause = (ReplyException) event.cause();
String failMessage = cause.getMessage();
int failCode = cause.failureCode();
}
});

关于error-handling - 顶点 : How to get fail() status code in failure handler?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37769990/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com