异常打印2
This commit is contained in:
parent
1dfc594a29
commit
3cb39035ed
|
|
@ -4,10 +4,8 @@ import cn.dev33.satoken.exception.NotLoginException;
|
|||
import cn.dev33.satoken.exception.NotPermissionException;
|
||||
import cn.dev33.satoken.exception.NotRoleException;
|
||||
import cn.hutool.core.exceptions.ValidateException;
|
||||
import cn.hutool.core.io.resource.NoResourceException;
|
||||
import com.czg.resp.CzgRespCode;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.support.DefaultMessageSourceResolvable;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
|
|
@ -142,24 +140,24 @@ public class CzgControllerAdvice {
|
|||
return CzgResult.failure(CzgRespCode.RECORD_EXISTED);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@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());
|
||||
}
|
||||
// @ResponseBody
|
||||
// @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());
|
||||
// }
|
||||
|
||||
private void setErrorLog(Exception ex) {
|
||||
// log.error(ex.getMessage());
|
||||
|
|
|
|||
Loading…
Reference in New Issue