|
@@ -17,6 +17,8 @@ import org.springframework.web.servlet.NoHandlerFoundException;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.validation.ConstraintViolationException;
|
|
|
import javax.validation.ValidationException;
|
|
|
+import java.io.PrintWriter;
|
|
|
+import java.io.StringWriter;
|
|
|
|
|
|
/**
|
|
|
* 统一捕捉异常,自定义返回参数
|
|
@@ -72,7 +74,7 @@ public class ExceptionController {
|
|
|
public Result runtimeExceptionHandler(HttpServletRequest request, BaseRuntimeException e) {
|
|
|
log.error(request.getRequestURI() + ":" + e.getMsg());
|
|
|
// by owen 2022-3-28 显示错误日志详情
|
|
|
- e.printStackTrace();
|
|
|
+ printErrorMsg(e);
|
|
|
return Result.failure(e.getCode(), e.getMsg());
|
|
|
}
|
|
|
|
|
@@ -125,6 +127,16 @@ public class ExceptionController {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * by owen 2022-4-1
|
|
|
+ * 打印错误详情
|
|
|
+ * @param e
|
|
|
+ */
|
|
|
+ private void printErrorMsg(BaseRuntimeException e){
|
|
|
+ StringWriter trace=new StringWriter();
|
|
|
+ e.printStackTrace(new PrintWriter(trace));
|
|
|
+ log.error(trace);
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|