| | |
| | | @ExceptionHandler(NullPointerException.class) |
| | | public ResponseResult nullPointerExceptionHandler(NullPointerException e) { |
| | | e.printStackTrace(); |
| | | return ResponseResult.error("A null object appeared."); |
| | | return ResponseResult.error("出现空对象"); |
| | | } |
| | | |
| | | @ExceptionHandler({MethodArgumentNotValidException.class, BindException.class}) |
| | | public ResponseResult methodArgumentNotValidExceptionHandler(BindException e) { |
| | | e.printStackTrace(); |
| | | return ResponseResult.error(e.getBindingResult().getAllErrors().get(0).getDefaultMessage()); |
| | | return ResponseResult.error(e.getFieldError().getField() + e.getFieldError().getDefaultMessage()); |
| | | } |
| | | |
| | | } |