20230219
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package xyz.zhouxy.plusone.exception.handler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import xyz.zhouxy.plusone.exception.SysException;
|
||||
import xyz.zhouxy.plusone.util.RestfulResult;
|
||||
|
||||
@RestControllerAdvice
|
||||
@Slf4j
|
||||
public class SysExceptionHandler extends BaseExceptionHandler {
|
||||
|
||||
public SysExceptionHandler(ExceptionInfoHolder exceptionInfoHolder) {
|
||||
super(exceptionInfoHolder);
|
||||
}
|
||||
|
||||
@ExceptionHandler({ SysException.class })
|
||||
public ResponseEntity<RestfulResult> handleException(@Nonnull Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
HttpStatus httpStatus = getHttpStatus(e);
|
||||
return new ResponseEntity<>(RestfulResult.error(getErrorCode(e), "系统错误"), httpStatus);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user