List of usage examples for org.springframework.beans TypeMismatchException getValue
@Override
@Nullable
public Object getValue()
From source file:org.easyj.rest.controller.AbstractController.java
@ResponseStatus(value = HttpStatus.BAD_REQUEST) @ExceptionHandler(TypeMismatchException.class) public ModelAndView handleTypeMismatch(TypeMismatchException e) { BindingResult result = createBindingResult(getClass()); result.addError(new FieldError("param.bind", e.getRequiredType().getSimpleName(), e.getValue(), true, null, null, "error.param.bind.type")); return configMAV(null, result, "errors/badrequest"); }
From source file:org.apigw.authserver.web.admin.DefaultAdminExceptionHandler.java
@ExceptionHandler(TypeMismatchException.class) @ResponseStatus(HttpStatus.NOT_FOUND)// w w w. ja v a 2 s. co m public @ResponseBody Map<String, Object> handleTypeMismatch(TypeMismatchException e) { Map<String, Object> map = Maps.newHashMap(); map.put("error", "Type mismatch"); map.put("cause", "Argument with the value " + e.getValue() + " is not valid"); log.info("Handle TypeMismatch. Returning {}", map); return map; }
From source file:se.skltp.cooperation.web.rest.exception.DefaultExceptionHandler.java
@ExceptionHandler(TypeMismatchException.class) @ResponseStatus(HttpStatus.BAD_REQUEST)//from w w w .ja v a 2 s. c o m public @ResponseBody ProblemDetail handleTypeMismatch(HttpServletRequest request, TypeMismatchException e) throws Exception { ProblemDetail error = new ProblemDetail(); buildErrorMessage(request, e, HttpStatus.BAD_REQUEST, error); error.setDetail("Argument with the value " + e.getValue() + " is not valid"); return error; }
From source file:org.openmrs.module.radiology.web.controller.PortletsController.java
/** * Handle all exceptions of type TypeMismatchException which occur in this class * //from www. jav a 2 s. com * @param TypeMismatchException the thrown TypeMismatchException * @return model and view with exception information * @should populate model with exception text from message properties and invalid value if date * is expected but nut passed * @should should populate model with exception text */ @ExceptionHandler(TypeMismatchException.class) public ModelAndView handleTypeMismatchException(TypeMismatchException ex) { log.error(ex.getMessage()); ModelAndView mav = new ModelAndView(); if (ex.getRequiredType().equals(Date.class)) { mav.addObject("invalidValue", ex.getValue()); mav.addObject("exceptionText", "typeMismatch.java.util.Date"); } else { mav.addObject("exceptionText", ex.getMessage()); } return mav; }
From source file:net.duckling.ddl.web.agent.csp.CspBaseController.java
@ExceptionHandler public void exp(HttpServletRequest request, HttpServletResponse response, Exception ex) { if (ex instanceof MissingServletRequestParameterException) { MissingServletRequestParameterException me = (MissingServletRequestParameterException) ex; ErrorMsg msg = ErrorMsg.MISSING_PARAMETER; msg.setMsg("Required parameter [" + me.getParameterName() + "] is missing."); writeError(msg, request, response); } else if (ex instanceof TypeMismatchException) { TypeMismatchException te = (TypeMismatchException) ex; ErrorMsg msg = ErrorMsg.TYPE_MISMATCH; msg.setMsg("Value [" + te.getValue() + "] of type is mismatch."); writeError(msg, request, response); } else {// ww w.ja v a2 s. c o m writeError(ErrorMsg.UNKNOW_ERROR, request, response); } }
From source file:org.openmrs.module.radiology.order.web.PortletsController.java
/** * Handle all exceptions of type TypeMismatchException which occur in this class * /*from ww w . j av a 2s . com*/ * @param typeMismatchException TypeMismatchException the thrown TypeMismatchException * @return model and view with exception information * @should populate model with exception text from message properties and invalid value if date * is expected but nut passed * @should should populate model with exception text */ @ExceptionHandler(TypeMismatchException.class) public ModelAndView handleTypeMismatchException(TypeMismatchException typeMismatchException) { log.error(typeMismatchException.getMessage()); final ModelAndView mav = new ModelAndView(); if (typeMismatchException.getRequiredType().equals(Date.class)) { mav.addObject("invalidValue", typeMismatchException.getValue()); mav.addObject("exceptionText", "typeMismatch.java.util.Date"); } else { mav.addObject("exceptionText", typeMismatchException.getMessage()); } return mav; }