コード例 #1
0
 @ExceptionHandler(MethodArgumentTypeMismatchException.class)
 public static ResponseEntity<?> handleMethodArgumentTypeMismatchException(
     final MethodArgumentTypeMismatchException exception) {
   final Throwable cause = exception.getCause();
   if (cause instanceof ConversionFailedException) {
     return handleConversionFailedException((ConversionFailedException) cause);
   } else {
     return sendError(HttpStatus.BAD_REQUEST, exception.getMessage());
   }
 }
コード例 #2
0
 @ExceptionHandler({MethodArgumentTypeMismatchException.class})
 public void badArguments(HttpServletResponse res, MethodArgumentTypeMismatchException e)
     throws IOException {
   res.sendError(BAD_REQUEST.value(), String.format(MSG_TEMPLATE, e.getName(), e.getValue()));
 }