default Optional<Location> find(final T throwable) { final ExceptionTranslator exceptionTranslator = this.getExceptionTranslator(); return exceptionTranslator != null ? exceptionTranslator.find(throwable) : Optional.empty(); }
/** * Translate exception and generates localizedMessage. * * @param request The current request. * @param location The location get data from. * @param throwable throwable * @return A TranslateResult. */ default Optional<String> localizedMessage( // final RequestAttributes request, // final Location location, // final T throwable // ) { final ExceptionTranslator exceptionTranslator = this.getExceptionTranslator(); final Optional<String> result; if (exceptionTranslator != null) { final Map<String, Serializable> contextVariables = ImmutableMap.of(); final String template = exceptionTranslator.template(location).orElse(null); result = exceptionTranslator.localizedMessage(template, request, throwable, contextVariables); } else { result = Optional.empty(); } return result; }
@Deprecated static HierarchicalMessageSource rootMessageSource(final MessageSource messageSource) { final HierarchicalMessageSource result; if (messageSource instanceof HierarchicalMessageSource) { final MessageSource parent = ((HierarchicalMessageSource) messageSource).getParentMessageSource(); result = parent != null ? // rootMessageSource(parent) // : (HierarchicalMessageSource) messageSource; // } else { result = null; } return result; }
default Optional<Integer> status( // final RequestAttributes requestAttributes, // final Location location, // final T throwable // ) { final ExceptionTranslator exceptionTranslator = this.getExceptionTranslator(); final Optional<Integer> translated = exceptionTranslator != null ? // exceptionTranslator.status(location) : // Optional.empty(); final Integer fromAttribute = this.getAttribute(requestAttributes, "javax.servlet.error.status_code"); return translated.isPresent() ? translated : Optional.ofNullable(fromAttribute); }
@Override public Optional<String> localizedMessage( // final RequestAttributes requestAttributes, // final ExceptionTranslator.Location location, // final ApplicationException throwable // ) { final Map<String, Serializable> contextVariables = throwable.getContextVariables(); final String template = throwable.getTemplate(); return this.exceptionTranslator.localizedMessage( // template, // requestAttributes, // throwable, // contextVariables // ); } }
default Optional<Integer> status( // final RequestAttributes requestAttributes, // final Location location, // final T throwable // ) { final ExceptionTranslator exceptionTranslator = this.getExceptionTranslator(); final Optional<Integer> translated = exceptionTranslator != null ? // exceptionTranslator.status(location) : // Optional.empty(); final Integer fromAttribute = this.getAttribute(requestAttributes, "javax.servlet.error.status_code"); return translated.isPresent() ? translated : Optional.ofNullable(fromAttribute); }
@Override public Optional<String> localizedMessage( // final RequestAttributes requestAttributes, // final ExceptionTranslator.Location location, // final ApplicationException throwable // ) { final Map<String, Serializable> contextVariables = throwable.getContextVariables(); final String template = throwable.getTemplate(); return this.exceptionTranslator.localizedMessage( // template, // requestAttributes, // throwable, // contextVariables // ); } }
/** * Translate exception and generates localizedMessage. * * @param request The current request. * @param location The location get data from. * @param throwable throwable * @return A TranslateResult. */ default Optional<String> localizedMessage( // final RequestAttributes request, // final Location location, // final T throwable // ) { final ExceptionTranslator exceptionTranslator = this.getExceptionTranslator(); final Optional<String> result; if (exceptionTranslator != null) { final Map<String, Serializable> contextVariables = ImmutableMap.of(); final String template = exceptionTranslator.template(location).orElse(null); result = exceptionTranslator.localizedMessage(template, request, throwable, contextVariables); } else { result = Optional.empty(); } return result; }
default Optional<Location> find(final T throwable) { final ExceptionTranslator exceptionTranslator = this.getExceptionTranslator(); return exceptionTranslator != null ? exceptionTranslator.find(throwable) : Optional.empty(); }
@Deprecated static HierarchicalMessageSource rootMessageSource(final MessageSource messageSource) { final HierarchicalMessageSource result; if (messageSource instanceof HierarchicalMessageSource) { final MessageSource parent = ((HierarchicalMessageSource) messageSource).getParentMessageSource(); result = parent != null ? // rootMessageSource(parent) // : (HierarchicalMessageSource) messageSource; // } else { result = null; } return result; }