コード例 #1
0
 @Ignore
 @ExceptionHandler(value = MissingServletRequestParameterException.class)
 public @ResponseBody ResponseEntity<String> catchMissingServletRequestParameterException(
     MissingServletRequestParameterException exception) {
   LOGGER.error("REST Wrong Input Parameters Exception: " + exception.getMessage(), exception);
   return JsonRestUtils.toJsonResponse(
       HttpStatus.BAD_REQUEST, new ErrorResponse(BUSINESS_ERROR_CODE, exception.getMessage()));
 }
コード例 #2
0
 /** indicates a missing parameter. */
 @ExceptionHandler(MissingServletRequestParameterException.class)
 public ResponseEntity<Map<String, Object>> handleMissingServletRequestParameterException(
     MissingServletRequestParameterException error) {
   Map<String, Object> errorMap = new HashMap<String, Object>();
   errorMap.put("hasErrors", "true");
   errorMap.put(
       "developerMessage",
       "the request parameter ["
           + error.getParameterName()
           + "] of type ["
           + error.getParameterType()
           + "]is missing");
   errorMap.put("userMessage", "please provide all the values");
   errorMap.put("moreInfo", error.getMessage());
   errorMap.put("errorCode", HttpStatus.BAD_REQUEST);
   error.printStackTrace();
   return new ResponseEntity<Map<String, Object>>(errorMap, HttpStatus.BAD_REQUEST);
 }