|
@@ -29,30 +29,30 @@ public class GlobalRestExceptionHandler {
|
|
|
*/
|
|
|
@ExceptionHandler(Throwable.class)
|
|
|
public ResponseError exception(Exception e) {
|
|
|
- ResponseError errorHandler = ResponseError.data(e.getClass().getName());
|
|
|
+ ResponseError responseError = ResponseError.data(e.getClass().getName());
|
|
|
|
|
|
if (e instanceof CustomException) {
|
|
|
- errorHandler.setMessage(e.getMessage());
|
|
|
+ responseError.setMessage(e.getMessage());
|
|
|
}
|
|
|
if (e instanceof ErrorResponse) {
|
|
|
- errorHandler.setCode(((ErrorResponse)e).getStatusCode().value());
|
|
|
- errorHandler.setMessage(e.getMessage());
|
|
|
+ responseError.setCode(((ErrorResponse)e).getStatusCode().value());
|
|
|
+ responseError.setMessage(e.getMessage());
|
|
|
}
|
|
|
if (e instanceof SaTokenException) {
|
|
|
- errorHandler.setCode(((SaTokenException)e).getCode());
|
|
|
- errorHandler.setMessage("账户未登录");
|
|
|
+ responseError.setCode(((SaTokenException)e).getCode());
|
|
|
+ responseError.setMessage("账户未登录");
|
|
|
}
|
|
|
|
|
|
- LogError errorHandlerToLogError = new LogError().castErrorHandlerToLogError(errorHandler);
|
|
|
+ LogError errorHandlerToLogError = new LogError().castResponseErrorToLogError(responseError);
|
|
|
errorHandlerToLogError.setErrorInfo(e.getMessage());
|
|
|
errorHandlerToLogError.setErrorStackTrace(Arrays.toString(e.getStackTrace()));
|
|
|
logErrorService.insertOne(errorHandlerToLogError);
|
|
|
|
|
|
- Log.error(e.getClass(), "Code ====> {}", errorHandler.getCode());
|
|
|
- Log.error(e.getClass(), "Exception ====> {}", errorHandler.getException());
|
|
|
- Log.error(e.getClass(), "Message ====> {}", errorHandler.getMessage());
|
|
|
+ Log.error(e.getClass(), "Code ====> {}", responseError.getCode());
|
|
|
+ Log.error(e.getClass(), "Exception ====> {}", responseError.getException());
|
|
|
+ Log.error(e.getClass(), "Message ====> {}", responseError.getMessage());
|
|
|
Log.error(e.getClass(), "ErrInfo ====> {}", e.getMessage());
|
|
|
|
|
|
- return errorHandler;
|
|
|
+ return responseError;
|
|
|
}
|
|
|
}
|