/** * 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; }
@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 // ); } }
@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 // ); } }