#[non_exhaustive]
pub struct DataError { pub kind: DataErrorKind, pub key: Option<ResourceKey>, pub str_context: Option<&'static str>, }
Expand description

The error type for ICU4X data provider operations.

To create one of these, either start with a DataErrorKind or use DataError::custom().

Example

Create a NeedsVariant error and attach a data request for context:

let key: ResourceKey = unimplemented!();
let req: &DataRequest = unimplemented!();
DataErrorKind::NeedsVariant.with_req(key, req);

Create a named custom error:

DataError::custom("This is an example error");

Fields (Non-exhaustive)

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
kind: DataErrorKind

Broad category of the error.

key: Option<ResourceKey>

The data key of the request, if available.

str_context: Option<&'static str>

Additional context, if available.

Implementations

Returns a new, empty DataError with kind Custom and a string error message.

Sets the resource key of a DataError, returning a modified error.

Sets the string context of a DataError, returning a modified error.

Sets the string context of a DataError to the given type name, returning a modified error.

Logs the data error with the given request, returning an error containing the resource key.

If the “log_error_context” feature is enabled, this logs the whole request. Either way, it returns an error with the resource key portion of the request as context.

Logs the data error with the given context, then return self.

This does not modify the error, but if the “log_error_context” feature is enabled, it will print out the context.

Logs the data error with the given context, then return self.

This does not modify the error, but if the “log_error_context” feature is enabled, it will print out the context.

Logs the data error with the given context, then return self.

This does not modify the error, but if the “log_error_context” feature is enabled, it will print out the context.

Logs the data error with the given context, then return self.

This does not modify the error, but if the “log_error_context” feature is enabled, it will print out the context.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

The lower-level source of this error, if any. Read more

🔬 This is a nightly-only experimental API. (backtrace)

Returns a stack backtrace, if available, of where this error occurred. Read more

👎 Deprecated since 1.42.0:

use the Display impl or to_string()

👎 Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Adds separators according to the given SeparatorPolicy. Read more

Inserts a comma every three digits from the right. Read more

Inserts a space every three digits from the right. Read more

Inserts a period every three digits from the right. Read more

Inserts an underscore every three digits from the right. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.