Skip to main content

L10nError

Enum L10nError 

Source
#[non_exhaustive]
pub enum L10nError { Decompression(String), InvalidUtf8(FromUtf8Error), InvalidLanguage { lang: String, reason: String, }, Builtins(String), ResourceParse(Vec<String>), AddResource(Vec<String>), MessageNotFound { id: String, }, MessageHasNoValue { id: String, }, AttributeNotFound { id: String, attribute: String, }, Format { id: String, attribute: Option<String>, errors: Vec<String>, }, }
Expand description

An error from loading a localization bundle or formatting one of its messages at runtime.

Returned by L10nBundle, L10nLanguageVec and the generated L10nLanguage::new. The generated message accessors unwrap this: a failure there means the generated code and the embedded .ftl have drifted apart, which is a build-time bug rather than something to handle at runtime.

The variants carry owned strings rather than fluent-bundle’s own error types on purpose, so this enum does not change shape when that (pre-1.0) dependency is updated. It is #[non_exhaustive] so new variants can be added in a minor release.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Decompression(String)

The user-supplied decompressor (for a compressed single-file build) returned an error. Carries that error’s message.

§

InvalidUtf8(FromUtf8Error)

The .ftl bytes were not valid UTF-8.

§

InvalidLanguage

The language identifier (e.g. "en-US") could not be parsed.

Fields

§lang: String

The identifier that failed to parse.

§reason: String

A human-readable description of why it failed.

§

Builtins(String)

The Fluent builtins (NUMBER, …) could not be registered on the bundle.

§

ResourceParse(Vec<String>)

The .ftl resource failed to parse. One entry per parser error.

§

AddResource(Vec<String>)

The resource could not be added to the bundle (e.g. a message id that collides with one already present).

§

MessageNotFound

No message with this id exists in the bundle.

Fields

§id: String

The message id that was looked up.

§

MessageHasNoValue

The message exists but has no value of its own (it has only attributes).

Fields

§id: String

The message id that was looked up.

§

AttributeNotFound

The message exists but has no attribute with this name.

Fields

§id: String

The message id.

§attribute: String

The attribute that was looked up.

§

Format

Formatting the message or attribute failed — typically a missing or wrongly-typed argument. One entry per formatting error.

Fields

§id: String

The message id being formatted.

§attribute: Option<String>

The attribute being formatted, if any.

§errors: Vec<String>

One entry per formatting error reported by fluent-bundle.

Trait Implementations§

Source§

impl Debug for L10nError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for L10nError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for L10nError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.