Commit f7102990 authored by wujiang's avatar wujiang

提交默认异常配置

parent cbec0fa5
......@@ -30,7 +30,7 @@ import lombok.extern.slf4j.Slf4j;
@Primary
public class GlobalExceptionHandler {
@Value ("${exception.debug}")
@Value("${exception.debug:false}")
private boolean debug;
/**
......@@ -48,6 +48,7 @@ public class GlobalExceptionHandler {
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
response.setTraceId(RequestContext.getTraceId());
response.setPath(request.getServletPath());
if (debug) {
// 获取异常的堆栈跟踪信息
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
......@@ -55,6 +56,10 @@ public class GlobalExceptionHandler {
String stackTrace = sw.toString();
response.setDevMessage(stackTrace);
response.setMessage(stackTrace);
} else {
response.setDevMessage(e.getMessage());
response.setMessage(e.getMessage());
}
return response;
}
......
exception.debug=true
## DB properties:
spring.datasource.dynamic.primary= mysql-service
spring.datasource.mysql-service.driver-class-name=com.mysql.cj.jdbc.Driver
......
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