mirror of
https://github.com/pppscn/SmsForwarder
synced 2024-11-08 01:10:23 +00:00
优化:服务端捕获 HttpException 仍返回 http 200(报文的code不是200),方便客户端展示错误信息
This commit is contained in:
parent
5712c32ff3
commit
d2969ef213
@ -15,10 +15,13 @@ class AppExceptionResolver : ExceptionResolver {
|
||||
override fun onResolve(request: HttpRequest, response: HttpResponse, e: Throwable) {
|
||||
e.printStackTrace()
|
||||
if (e is HttpException) {
|
||||
response.status = e.statusCode
|
||||
//response.status = e.statusCode
|
||||
//异常捕获返回 http 200
|
||||
response.status = StatusCode.SC_OK
|
||||
} else {
|
||||
response.status = StatusCode.SC_INTERNAL_SERVER_ERROR
|
||||
}
|
||||
|
||||
//返回统一结构报文
|
||||
response.setBody(JsonBody(HttpServerUtils.response(e.message.toString())))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user