default Optional<Location> find(final T throwable) { final ExceptionTranslator exceptionTranslator = this.getExceptionTranslator(); return exceptionTranslator != null ? exceptionTranslator.find(throwable) : Optional.empty(); }
default Optional<Location> find(final T throwable) { final ExceptionTranslator exceptionTranslator = this.getExceptionTranslator(); return exceptionTranslator != null ? exceptionTranslator.find(throwable) : Optional.empty(); }
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); }
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); }
/** * 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; }
/** * 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; }