use of org.summerb.approaches.validation.ValidationErrors in project summerb by skarpushin.
the class RestAuthenticationFailureHandler method onAuthenticationFailure.
@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
FieldValidationException fve = ExceptionUtils.findExceptionOfType(exception, FieldValidationException.class);
if (fve != null) {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
jsonResponseHelper.writeResponseBody(new ValidationErrors(fve.getErrors()), response);
return;
}
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
GenericServerErrorResult responseBody = new GenericServerErrorResult(exceptionTranslator.buildUserMessage(exception, LocaleContextHolder.getLocale()), new ExceptionInfo(exception));
jsonResponseHelper.writeResponseBody(responseBody, response);
}
Aggregations