Commit c2463909 authored by liaozan's avatar liaozan 🏀

Release 3.0.3

parent cf4fb49e
...@@ -2,7 +2,6 @@ package com.schbrain.common.web.exception; ...@@ -2,7 +2,6 @@ package com.schbrain.common.web.exception;
import cn.hutool.core.exceptions.ExceptionUtil; import cn.hutool.core.exceptions.ExceptionUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.schbrain.common.constants.ResponseActionConstants;
import com.schbrain.common.exception.BaseException; import com.schbrain.common.exception.BaseException;
import com.schbrain.common.util.EnvUtils; import com.schbrain.common.util.EnvUtils;
import com.schbrain.common.web.result.ResponseDTO; import com.schbrain.common.web.result.ResponseDTO;
...@@ -41,8 +40,8 @@ public class DefaultGlobalExceptionHandler implements GlobalExceptionHandler { ...@@ -41,8 +40,8 @@ public class DefaultGlobalExceptionHandler implements GlobalExceptionHandler {
/************************************* Base Exception Handing *************************************/ /************************************* Base Exception Handing *************************************/
@ExceptionHandler(BaseException.class) @ExceptionHandler(BaseException.class)
public ResponseDTO<String> handleBaseException(BaseException ex) { public ResponseDTO<String> handleBaseException(BaseException ex) {
log.error(ex.getMessage()); logError(ex);
return buildResponse(ex, ex.getCode(), ex.getAction(), ex.getMessage()); return ResponseDTO.error(ex);
} }
/************************************* Common Exception Handing *************************************/ /************************************* Common Exception Handing *************************************/
...@@ -200,19 +199,15 @@ public class DefaultGlobalExceptionHandler implements GlobalExceptionHandler { ...@@ -200,19 +199,15 @@ public class DefaultGlobalExceptionHandler implements GlobalExceptionHandler {
} }
protected ResponseDTO<String> buildResponse(Throwable throwable, int code, String message) { protected ResponseDTO<String> buildResponse(Throwable throwable, int code, String message) {
return buildResponse(throwable, code, ResponseActionConstants.ALERT, message);
}
protected ResponseDTO<String> buildResponse(Throwable throwable, int code, int action, String message) {
boolean isProduction = EnvUtils.isProduction(); boolean isProduction = EnvUtils.isProduction();
ResponseDTO<String> responseDTO = getExceptionResponseMapping(throwable, isProduction); ResponseDTO<String> responseDTO = getExceptionResponseMapping(throwable, isProduction);
if (responseDTO != null) { if (responseDTO != null) {
return responseDTO; return responseDTO;
} }
if (isProduction || StringUtils.isBlank(message)) { if (isProduction || StringUtils.isBlank(message)) {
return ResponseDTO.error("系统错误", code, action); return ResponseDTO.error("系统错误", code);
} }
return ResponseDTO.error(message, code, action); return ResponseDTO.error(message, code);
} }
protected ResponseDTO<String> getExceptionResponseMapping(Throwable throwable, boolean isProduction) { protected ResponseDTO<String> getExceptionResponseMapping(Throwable throwable, boolean isProduction) {
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
</distributionManagement> </distributionManagement>
<properties> <properties>
<revision>3.0.2-SNAPSHOT</revision> <revision>3.0.3</revision>
<java.version>11</java.version> <java.version>11</java.version>
<!-- 2th part versions --> <!-- 2th part versions -->
<schbrain-apollo.version>${revision}</schbrain-apollo.version> <schbrain-apollo.version>${revision}</schbrain-apollo.version>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment