使用 UnifiedResponse 替代 RestfulResult
This commit is contained in:
@@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler;
|
||||
import xyz.zhouxy.plusone.commons.util.RestfulResult;
|
||||
import xyz.zhouxy.plusone.commons.util.UnifiedResponse;
|
||||
|
||||
/**
|
||||
* 默认异常的处理器
|
||||
@@ -62,7 +62,7 @@ public class DefaultExceptionHandler extends BaseExceptionHandler {
|
||||
DataAccessException.class,
|
||||
MethodArgumentNotValidException.class
|
||||
})
|
||||
public ResponseEntity<RestfulResult> handleException(Exception e) {
|
||||
public ResponseEntity<UnifiedResponse> handleException(Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return buildExceptionResponse(e);
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler;
|
||||
import xyz.zhouxy.plusone.commons.util.RestfulResult;
|
||||
import xyz.zhouxy.plusone.commons.util.UnifiedResponse;
|
||||
import xyz.zhouxy.plusone.exception.SysException;
|
||||
|
||||
@RestControllerAdvice
|
||||
@@ -21,9 +21,9 @@ public class SysExceptionHandler extends BaseExceptionHandler {
|
||||
}
|
||||
|
||||
@ExceptionHandler({ SysException.class })
|
||||
public ResponseEntity<RestfulResult> handleException(@Nonnull Exception e) {
|
||||
public ResponseEntity<UnifiedResponse> handleException(@Nonnull Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
HttpStatus httpStatus = getHttpStatus(e);
|
||||
return new ResponseEntity<>(RestfulResult.error(getErrorCode(e), "系统错误"), httpStatus);
|
||||
return new ResponseEntity<>(UnifiedResponse.error(getErrorCode(e), "系统错误"), httpStatus);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user