添加自动推荐标签功能
This commit is contained in:
@@ -7,10 +7,12 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.servlet.resource.NoResourceFoundException;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -41,6 +43,19 @@ public class GlobalExceptionHandler {
|
||||
return ApiResult.error(ErrorCode.FORBIDDEN);
|
||||
}
|
||||
|
||||
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
||||
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
|
||||
public ApiResult<Void> handleMethodNotSupported(HttpRequestMethodNotSupportedException e) {
|
||||
log.warn("Method not supported: {}", e.getMessage());
|
||||
return ApiResult.error(ErrorCode.METHOD_NOT_ALLOWED);
|
||||
}
|
||||
|
||||
@ExceptionHandler(NoResourceFoundException.class)
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
public ApiResult<Void> handleNoResourceFound(NoResourceFoundException e) {
|
||||
return ApiResult.error(ErrorCode.NOT_FOUND);
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
public ApiResult<Void> handleException(Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user