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) {