use of com.tyndalehouse.step.core.exceptions.ValidationException in project step by STEPBible.
the class AbstractAjaxController method getExceptionMessageAndLog.
/**
* Gets the exception message.
*
* @param e the e
* @return the exception message
*/
private String getExceptionMessageAndLog(final Throwable e) {
LOGGER.trace("Tracing exception: ", e);
final Locale locale = this.clientSessionProvider.get().getLocale();
final ResourceBundle bundle = ResourceBundle.getBundle("ErrorBundle", locale);
if (!(e instanceof StepInternalException)) {
return returnInternalError(e, bundle);
}
// else we're looking at a STEP caught exception
if (e instanceof LocalisedException) {
return e.getMessage();
}
if (e instanceof TranslatedException) {
final TranslatedException translatedException = (TranslatedException) e;
LOGGER.warn(e.getMessage());
LOGGER.debug(e.getMessage(), e);
return format(bundle.getString(translatedException.getMessage()), translatedException.getArgs());
}
if (e instanceof ValidationException) {
final ValidationException validationException = (ValidationException) e;
switch(validationException.getExceptionType()) {
case LOGIN_REQUIRED:
return bundle.getString("error_login");
case USER_MISSING_FIELD:
return bundle.getString("error_missing_field");
case USER_VALIDATION_ERROR:
return bundle.getString("error_validation");
case APP_MISSING_FIELD:
case CONTROLLER_INITIALISATION_ERROR:
case SERVICE_VALIDATION_ERROR:
default:
return returnInternalError(e, bundle);
}
}
return returnInternalError(e, bundle);
}
Aggregations