最新代码

This commit is contained in:
admin
2024-04-19 17:20:40 +08:00
parent e4032a0183
commit 993f975edd
82 changed files with 2618 additions and 248 deletions

View File

@@ -1,16 +1,19 @@
package com.starry.admin.common.exception.handler;
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import com.starry.admin.common.exception.CustomException;
import com.starry.admin.common.exception.ServiceException;
import com.starry.common.result.R;
import com.starry.common.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
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;
@@ -79,6 +82,22 @@ public class GlobalExceptionHandler {
return R.error("请求参数异常," + errorMessageBuilder);
}
@ExceptionHandler(MismatchedInputException.class)
public R mismatchedInputException(MismatchedInputException e) {
return R.error("请求参数格式异常");
}
@ExceptionHandler(HttpMessageNotReadableException.class)
public R httpMessageNotReadableException(HttpMessageNotReadableException e) {
return R.error("请求参数格式异常");
}
@ExceptionHandler(MissingServletRequestParameterException.class)
public R missingServletRequestParameterException(MissingServletRequestParameterException e) {
return R.error("请求参数格式异常");
}
/**
* 自定义异常
*
@@ -89,10 +108,5 @@ public class GlobalExceptionHandler {
return R.error(e.getMessage());
}
// @ExceptionHandler(ServiceException.class)
// public R serviceException(ServiceException e) {
// return R.error(e.getMessage());
// }
}