seata 异常 日志
This commit is contained in:
parent
ae0e85fb04
commit
033db28c0b
|
|
@ -34,6 +34,17 @@ public class CzgControllerAdvice {
|
|||
@ExceptionHandler(value = Exception.class)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public CzgResult<Object> errorHandler(Exception ex) {
|
||||
Throwable rootCause = ex;
|
||||
while (rootCause.getCause() != null) {
|
||||
rootCause = rootCause.getCause();
|
||||
if (rootCause instanceof CzgException) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 处理自定义异常
|
||||
if (rootCause instanceof CzgException czgException) {
|
||||
return CzgResult.failure(czgException.getCode(), czgException.getMessage());
|
||||
}
|
||||
setErrorLog(ex);
|
||||
return CzgResult.failure(CzgRespCode.SYSTEM_ERROR.getCode(), ex.getMessage());
|
||||
}
|
||||
|
|
@ -143,7 +154,7 @@ public class CzgControllerAdvice {
|
|||
}
|
||||
|
||||
private void setErrorLog(Exception ex) {
|
||||
log.error("错误",ex);
|
||||
log.error(ex.getMessage());
|
||||
log.error("错误",ex);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue