|
|
@@ -1,15 +1,17 @@
|
|
|
package com.aitori.exception;
|
|
|
|
|
|
-import com.dtflys.forest.exceptions.ForestRuntimeException;
|
|
|
import com.aitori.annotation.SkipResponseWrapper;
|
|
|
import com.aitori.dto.R;
|
|
|
+import com.dtflys.forest.exceptions.ForestRuntimeException;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
|
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
|
|
+import org.springframework.web.servlet.resource.NoResourceFoundException;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
@@ -48,6 +50,12 @@ public class GlobalExceptionHandle {
|
|
|
return R.fail(HttpStatus.BAD_REQUEST.value(), e.getMessage());
|
|
|
}
|
|
|
|
|
|
+ @ExceptionHandler(NoResourceFoundException.class)
|
|
|
+ public R<Void> handleNoResourceFound() {
|
|
|
+ // 直接返回404,不打印任何异常
|
|
|
+ return R.fail(HttpStatus.NOT_FOUND.value(), "Resource not found");
|
|
|
+ }
|
|
|
+
|
|
|
@ExceptionHandler(value = Exception.class)
|
|
|
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
|
|
public R<Void> exceptionHandle(Exception e) {
|