Class MissingTranslationException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.lokalized.MissingTranslationException
- All Implemented Interfaces:
Serializable
Exception thrown when no translation is found and the configured
TranslationFailureHandler chooses to throw.
This class is intended for use by a single thread.
Java serialization is supported when every non-null placeholder value and its reachable object graph implement
Serializable. Otherwise, serialization fails with NotSerializableException.
The supported serialized form begins with 3.0.0 and is not compatible with streams written by 2.x releases.
- Author:
- Mark Allen
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionMissingTranslationException(@NonNull String message, @NonNull String key, @NonNull Map<@NonNull String, @Nullable Object> placeholders, @NonNull Locale lookupLocale) Constructs a new missing-translation exception.MissingTranslationException(@NonNull String message, @NonNull String key, @NonNull Map<@NonNull String, @Nullable Object> placeholders, @NonNull Locale lookupLocale, @NonNull TranslationFailureReason reason, @NonNull List<@NonNull Locale> attemptedLocales) Constructs an exception with the complete failed-lookup outcome.MissingTranslationException(@NonNull String message, @NonNull String key, @NonNull Map<@NonNull String, @Nullable Object> placeholders, @NonNull Locale lookupLocale, @Nullable LocaleMatchResult localeMatchResult, @NonNull TranslationFailureReason reason, @NonNull List<@NonNull Locale> attemptedLocales) Constructs an exception with complete failed-lookup and locale-negotiation diagnostics. -
Method Summary
Modifier and TypeMethodDescriptionGets the ordered locales attempted before failure.getKey()The translation key that triggered this exception.Gets strict locale-negotiation diagnostics when available.The locale used to begin per-key locale fallback.The placeholders specified for the failed translation attempt.Gets the final failure reason.Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
MissingTranslationException
public MissingTranslationException(@NonNull String message, @NonNull String key, @NonNull Map<@NonNull String, @Nullable Object> placeholders, @NonNull Locale lookupLocale) Constructs a new missing-translation exception.- Parameters:
message- failure message, not nullkey- translation key, not nullplaceholders- caller placeholders, not nulllookupLocale- the locale used to begin locale fallback, not null- Throws:
IllegalArgumentException- if the lookup locale is malformed or the placeholders contain a null key
-
MissingTranslationException
public MissingTranslationException(@NonNull String message, @NonNull String key, @NonNull Map<@NonNull String, @Nullable Object> placeholders, @NonNull Locale lookupLocale, @NonNull TranslationFailureReason reason, @NonNull List<@NonNull Locale> attemptedLocales) Constructs an exception with the complete failed-lookup outcome.- Parameters:
message- failure message, not nullkey- translation key, not nullplaceholders- caller placeholders, not nulllookupLocale- locale used to begin locale fallback, not nullreason- final failure reason, not nullattemptedLocales- ordered locales attempted, not null- Throws:
IllegalArgumentException- if the placeholders contain a null key, any locale is malformed, attempted locales have duplicate language tags, or the reason isRESOLUTION_FAILURE- Since:
- 3.0.0
-
MissingTranslationException
public MissingTranslationException(@NonNull String message, @NonNull String key, @NonNull Map<@NonNull String, @Nullable Object> placeholders, @NonNull Locale lookupLocale, @Nullable LocaleMatchResult localeMatchResult, @NonNull TranslationFailureReason reason, @NonNull List<@NonNull Locale> attemptedLocales) Constructs an exception with complete failed-lookup and locale-negotiation diagnostics.- Parameters:
message- failure message, not nullkey- translation key, not nullplaceholders- caller placeholders, not nulllookupLocale- locale used to begin locale fallback, not nulllocaleMatchResult- strict locale-negotiation diagnostics, or null when unavailablereason- final failure reason, not nullattemptedLocales- ordered locales attempted, not null- Throws:
IllegalArgumentException- if the placeholders contain a null key, any locale is malformed, attempted locales have duplicate language tags, or the reason isRESOLUTION_FAILURE- Since:
- 3.0.0
-
-
Method Details
-
getKey
-
getPlaceholders
-
getLookupLocale
The locale used to begin per-key locale fallback.- Returns:
- the locale, not null
- Since:
- 3.0.0
-
getLocaleMatchResult
Gets strict locale-negotiation diagnostics when available.- Returns:
- strict locale-negotiation diagnostics when available, otherwise empty, not null
- Since:
- 3.0.0
-
getReason
Gets the final failure reason.- Returns:
- final failure reason, not null
- Since:
- 3.0.0
-
getAttemptedLocales
Gets the ordered locales attempted before failure.- Returns:
- ordered locales attempted before failure, not null
- Since:
- 3.0.0
-