mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-16 16:14:19 +08:00
新增资源分类管理
This commit is contained in:
@@ -4,8 +4,10 @@ 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.MissingServletRequestParameterException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
||||
import xyz.playedu.api.exception.NotFoundException;
|
||||
import xyz.playedu.api.exception.ServiceException;
|
||||
import xyz.playedu.api.types.JsonResponse;
|
||||
@@ -32,7 +34,7 @@ public class ExceptionController {
|
||||
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public JsonResponse serviceExceptionHandler(MethodArgumentNotValidException e) {
|
||||
StringBuffer errorMsg = new StringBuffer();
|
||||
StringBuilder errorMsg = new StringBuilder();
|
||||
List<ObjectError> allErrors = e.getBindingResult().getAllErrors();
|
||||
for (ObjectError tmpError : allErrors) {
|
||||
errorMsg.append(tmpError.getDefaultMessage()).append(",");
|
||||
@@ -46,6 +48,16 @@ public class ExceptionController {
|
||||
return JsonResponse.error("请求method错误", 400);
|
||||
}
|
||||
|
||||
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
|
||||
public JsonResponse serviceExceptionHandler(MethodArgumentTypeMismatchException e) {
|
||||
return JsonResponse.error("请求错误", 400);
|
||||
}
|
||||
|
||||
@ExceptionHandler(MissingServletRequestParameterException.class)
|
||||
public JsonResponse serviceExceptionHandler(MissingServletRequestParameterException e) {
|
||||
return JsonResponse.error("参数错误", 406);
|
||||
}
|
||||
|
||||
@ExceptionHandler(NotFoundException.class)
|
||||
public JsonResponse serviceExceptionHandler(NotFoundException e) {
|
||||
return JsonResponse.error(e.getMessage(), 404);
|
||||
|
||||
Reference in New Issue
Block a user