Struct DataError

struct DataError { ... }

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 IdentifierNotFound error and attach a data request for context:

# use icu_provider::prelude::*;
let marker: DataMarkerInfo = unimplemented!();
let req: DataRequest = unimplemented!();
DataErrorKind::IdentifierNotFound.with_req(marker, req);

Create a named custom error:

# use icu_provider::prelude::*;
DataError::custom("This is an example error");

Fields

kind: DataErrorKind

Broad category of the error.

marker: Option<DataMarkerId>

The data marker of the request, if available.

str_context: Option<&'static str>

Additional context, if available.

silent: bool

Whether this error was created in silent mode to not log.

Implementations

impl DataError

const fn custom(str_context: &'static str) -> Self

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

const fn with_marker(self: Self, marker: DataMarkerInfo) -> Self

Sets the data marker of a DataError, returning a modified error.

const fn with_str_context(self: Self, context: &'static str) -> Self

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

fn with_type_context<T>(self: Self) -> Self

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

fn with_req(self: Self, marker: DataMarkerInfo, req: DataRequest<'_>) -> Self

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

If the "logging" Cargo feature is enabled, this logs the whole request. Either way, it returns an error with the data marker portion of the request as context.

fn with_display_context<D: fmt::Display + ?Sized>(self: Self, context: &D) -> Self

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

This does not modify the error, but if the "logging" Cargo feature is enabled, it will print out the context.

fn with_debug_context<D: fmt::Debug + ?Sized>(self: Self, context: &D) -> Self

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

This does not modify the error, but if the "logging" Cargo feature is enabled, it will print out the context.

impl Clone for DataError

fn clone(self: &Self) -> DataError

impl Copy for DataError

impl Debug for DataError

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

impl Display for DataError

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

impl Eq for DataError

impl Error for DataError

impl Freeze for DataError

impl PartialEq for DataError

fn eq(self: &Self, other: &DataError) -> bool

impl RefUnwindSafe for DataError

impl Send for DataError

impl StructuralPartialEq for DataError

impl Sync for DataError

impl Unpin for DataError

impl UnsafeUnpin for DataError

impl UnwindSafe for DataError

impl<T> Any for DataError

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for DataError

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for DataError

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

impl<T> CloneToUninit for DataError

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> ErasedDestructor for DataError

impl<T> From for DataError

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for DataError

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T> ToString for DataError

fn to_string(self: &Self) -> String

impl<T, U> Into for DataError

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for DataError

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

impl<T, U> TryInto for DataError

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