Skip to content

Commit

Permalink
Update ControllerExceptionAdvice.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Qi-Zhen-xin authored Sep 6, 2023
1 parent be7c7fb commit bfe40df
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@

@RestControllerAdvice(basePackages = {"com.wz.score_assistant"})
public class ControllerExceptionAdvice {

@ExceptionHandler({BindException.class})
public ResultVo MethodArgumentNotValidExceptionHandler(BindException e) {
// 从异常对象中拿到ObjectError对象
ObjectError objectError = e.getBindingResult().getAllErrors().get(0);
return new ResultVo(ResultCode.VALIDATE_ERROR, objectError.getDefaultMessage());
}

@ExceptionHandler(APIException.class)
public ResultVo APIExceptionHandler(APIException e) {
// log.error(e.getMessage(), e); 由于还没集成日志框架,暂且放着,写上TODO
Expand Down

0 comments on commit bfe40df

Please sign in to comment.