Whenever a cloud endpoint throws an exception app engine handles those exceptions and sends standard response as follows.
每当云端点抛出异常时,应用程序引擎会处理这些异常并发送标准响应,如下所示。
{
"error" : {
"message" : "java.lang.ArithmeticException: / by zero",
"code" : 503,
"errors" : [ {
"domain" : "global",
"reason" : "backendError",
"message" : "java.lang.ArithmeticException: / by zero"
} ]
}
}
But I want to handle those exception in my custom filters and set relevant status code to response.
但是我想在自定义过滤器中处理这些异常并将相关的状态代码设置为响应。
Also sometimes I want to redirect to different url. How could I do that with endpoints?
有时我也想重定向到不同的网址。我怎么能用端点做到这一点?
1 个解决方案
#1
0
What you should do is set up an error handler as explained here. That way you can catch all of the standard exceptions thrown by endpoints or whatever custom exceptions you throw yourself.
您应该做的是设置一个错误处理程序,如此处所述。这样,您可以捕获端点抛出的所有标准异常或您自己抛出的任何自定义异常。
#1
0
What you should do is set up an error handler as explained here. That way you can catch all of the standard exceptions thrown by endpoints or whatever custom exceptions you throw yourself.
您应该做的是设置一个错误处理程序,如此处所述。这样,您可以捕获端点抛出的所有标准异常或您自己抛出的任何自定义异常。