From 6a5c6a2d38033a1466a12aa688b14f0e5cc61faf Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Wed, 4 Mar 2020 11:30:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A8=E5=B1=80=E9=94=99=E8=AF=AF=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/handler/RestControllerExceptionHandler.java | 3 +-- frontend/src/common/ajax.js | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/io/metersphere/controller/handler/RestControllerExceptionHandler.java b/backend/src/main/java/io/metersphere/controller/handler/RestControllerExceptionHandler.java index 6757af1563..352a56b338 100644 --- a/backend/src/main/java/io/metersphere/controller/handler/RestControllerExceptionHandler.java +++ b/backend/src/main/java/io/metersphere/controller/handler/RestControllerExceptionHandler.java @@ -24,8 +24,7 @@ public class RestControllerExceptionHandler { @ExceptionHandler(MSException.class) public ResultHolder msExceptionHandler(HttpServletRequest request, HttpServletResponse response, MSException e) { - // 自定义异常返回200 - response.setStatus(HttpStatus.OK.value()); + response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); return ResultHolder.error(e.getMessage()); } } diff --git a/frontend/src/common/ajax.js b/frontend/src/common/ajax.js index 41d11dbfc1..ab2e91df6a 100644 --- a/frontend/src/common/ajax.js +++ b/frontend/src/common/ajax.js @@ -48,7 +48,11 @@ export default { function exception(error, result) { result.loading = false; window.console.error(error.response || error.message); - Message.error({message: error.message, showClose: true}); + if (error.response.data) { + Message.error({message: error.response.data.message, showClose: true}); + } else { + Message.error({message: error.message, showClose: true}); + } } Vue.prototype.$get = function (url, success) {