use of org.molgenis.web.ErrorMessageResponse.ErrorMessage in project molgenis by molgenis.
the class RestController method handleMethodArgumentNotValidException.
@ExceptionHandler(MethodArgumentNotValidException.class)
@ResponseStatus(BAD_REQUEST)
public ErrorMessageResponse handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
LOG.debug("", e);
List<ErrorMessage> messages = Lists.newArrayList();
for (ObjectError error : e.getBindingResult().getAllErrors()) {
messages.add(new ErrorMessage(error.getDefaultMessage()));
}
return new ErrorMessageResponse(messages);
}
use of org.molgenis.web.ErrorMessageResponse.ErrorMessage in project molgenis by molgenis.
the class ErrorMessageResponseTest method ErrorMessageResponseListErrorMessage.
@Test
public void ErrorMessageResponseListErrorMessage() {
List<ErrorMessage> errorMessages = Arrays.asList(new ErrorMessage("message1"), new ErrorMessage("message2"));
ErrorMessageResponse errorMessageResponse = new ErrorMessageResponse(errorMessages);
assertEquals(errorMessageResponse.getErrors(), errorMessages);
}
Aggregations