mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-16 16:14:19 +08:00
图形验证码
This commit is contained in:
@@ -2,6 +2,7 @@ package xyz.playedu.api.controller;
|
||||
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.validation.ObjectError;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
@@ -19,17 +20,17 @@ public class ExceptionController {
|
||||
// }
|
||||
|
||||
@ExceptionHandler(ServiceException.class)
|
||||
public JsonResponse<String> serviceExceptionHandler(ServiceException e) {
|
||||
public JsonResponse serviceExceptionHandler(ServiceException e) {
|
||||
return JsonResponse.error(e.getMessage(), 1);
|
||||
}
|
||||
|
||||
@ExceptionHandler(HttpMessageNotReadableException.class)
|
||||
public JsonResponse<String> serviceExceptionHandler(HttpMessageNotReadableException e) {
|
||||
public JsonResponse serviceExceptionHandler(HttpMessageNotReadableException e) {
|
||||
return JsonResponse.error("参数为空", 406);
|
||||
}
|
||||
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public JsonResponse<String> serviceExceptionHandler(MethodArgumentNotValidException e) {
|
||||
public JsonResponse serviceExceptionHandler(MethodArgumentNotValidException e) {
|
||||
StringBuffer errorMsg = new StringBuffer();
|
||||
List<ObjectError> allErrors = e.getBindingResult().getAllErrors();
|
||||
for (ObjectError tmpError : allErrors) {
|
||||
@@ -39,4 +40,9 @@ public class ExceptionController {
|
||||
return JsonResponse.error(msg, 406);
|
||||
}
|
||||
|
||||
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
||||
public JsonResponse serviceExceptionHandler(HttpRequestMethodNotSupportedException e) {
|
||||
return JsonResponse.error("请求method错误", 400);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user