mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-28 05:56:22 +08:00
异常返回
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package xyz.playedu.api.controller;
|
package xyz.playedu.api.controller;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||||
import org.springframework.validation.ObjectError;
|
import org.springframework.validation.ObjectError;
|
||||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||||
@@ -15,12 +16,14 @@ import xyz.playedu.api.types.JsonResponse;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RestControllerAdvice
|
@RestControllerAdvice
|
||||||
|
@Slf4j
|
||||||
public class ExceptionController {
|
public class ExceptionController {
|
||||||
|
|
||||||
// @ExceptionHandler(Exception.class)
|
@ExceptionHandler(Exception.class)
|
||||||
// public JsonResponse exceptionHandler(Exception e) {
|
public JsonResponse exceptionHandler(Exception e) {
|
||||||
// return JsonResponse.error("系统错误", 500);
|
log.error(e.getMessage());
|
||||||
// }
|
return JsonResponse.error("系统错误", 500);
|
||||||
|
}
|
||||||
|
|
||||||
@ExceptionHandler(ServiceException.class)
|
@ExceptionHandler(ServiceException.class)
|
||||||
public JsonResponse serviceExceptionHandler(ServiceException e) {
|
public JsonResponse serviceExceptionHandler(ServiceException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user