fix:favicon.ico
This commit is contained in:
@@ -5,6 +5,7 @@ public enum ErrorCode {
|
||||
UNAUTHORIZED(4010, "未认证或认证失败"),
|
||||
SESSION_INVALID(4011, "会话无效"),
|
||||
FORBIDDEN(4030, "无权限访问"),
|
||||
NOT_FOUND(4040, "资源不存在"),
|
||||
VALIDATE_FAILED(4001, "参数校验失败"),
|
||||
CONFLICT(4090, "数据冲突"),
|
||||
BIZ_ERROR(5001, "业务处理异常"),
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.servlet.resource.NoResourceFoundException;
|
||||
import org.springframework.web.multipart.MaxUploadSizeExceededException;
|
||||
import org.springframework.web.multipart.MultipartException;
|
||||
|
||||
@@ -79,6 +80,16 @@ public class GlobalExceptionHandler {
|
||||
.withPath(request.getRequestURI()));
|
||||
}
|
||||
|
||||
@ExceptionHandler(NoResourceFoundException.class)
|
||||
public ResponseEntity<ApiResponse<Void>> handleNoResourceFound(NoResourceFoundException ex, HttpServletRequest request) {
|
||||
if ("/favicon.ico".equals(request.getRequestURI())) {
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
return response(HttpStatus.NOT_FOUND,
|
||||
ApiResponse.fail(ErrorCode.NOT_FOUND.getCode(), "resource not found")
|
||||
.withPath(request.getRequestURI()));
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ResponseEntity<ApiResponse<Void>> handleException(Exception ex, HttpServletRequest request) {
|
||||
log.error("Unhandled exception", ex);
|
||||
|
||||
Reference in New Issue
Block a user