调整,非成功响应情况下返回数据

This commit is contained in:
禾几海
2020-08-01 01:00:07 +08:00
parent d83e4de9a3
commit dcf44cefb6
2 changed files with 10 additions and 8 deletions

View File

@@ -39,8 +39,9 @@ public class ExceptionHandle {
public Response handle(Exception e) {
//自定义错误
if (e instanceof MyException) {
logger.debug("返回了自定义的exception,[code={},msg={}]", ((MyException) e).getCode(), e.getMessage());
return new Response(((MyException) e).getCode(), e.getMessage(), null);
MyException exception = (MyException) e;
logger.debug("返回了自定义的exception,[code={},msg={},result={}]", exception.getCode(), e.getMessage(), exception.getResult());
return new Response(exception.getCode(), e.getMessage(), exception.getResult());
}
//请求路径不支持该方法
if (e instanceof HttpRequestMethodNotSupportedException) {