diff --git a/components/calendar/src/error.rs b/components/calendar/src/error.rs index b62b5437da2..61f03ab7e42 100644 --- a/components/calendar/src/error.rs +++ b/components/calendar/src/error.rs @@ -29,6 +29,8 @@ pub enum DateError { UnknownMonthCode(MonthCode), } +impl core::error::Error for DateError {} + #[derive(Debug, Copy, Clone, PartialEq, Display)] /// An argument is out of range for its domain. #[displaydoc("The {field} = {value} argument is out of range {min}..={max}")] @@ -44,6 +46,8 @@ pub struct RangeError { pub max: i32, } +impl core::error::Error for RangeError {} + impl From for DateError { fn from(value: RangeError) -> Self { let RangeError { diff --git a/components/collections/src/codepointtrie/error.rs b/components/collections/src/codepointtrie/error.rs index a00b132c4f9..4cd157fc3f2 100644 --- a/components/collections/src/codepointtrie/error.rs +++ b/components/collections/src/codepointtrie/error.rs @@ -20,3 +20,5 @@ pub enum Error { #[displaydoc("CodePointTrie must be constructed from data vector with at least one element")] EmptyDataVector, } + +impl core::error::Error for Error {} diff --git a/components/datetime/src/builder.rs b/components/datetime/src/builder.rs index bd3cbb622b1..ef4629bce65 100644 --- a/components/datetime/src/builder.rs +++ b/components/datetime/src/builder.rs @@ -163,6 +163,8 @@ pub enum BuilderError { InvalidOptions, } +impl core::error::Error for BuilderError {} + /// A builder for [dynamic field sets](crate::fieldsets::enums). /// /// This builder is useful if you do not know the field set at code compilation time. If you do, diff --git a/components/datetime/src/error.rs b/components/datetime/src/error.rs index 2a9a7e8064e..cea3c19e6e4 100644 --- a/components/datetime/src/error.rs +++ b/components/datetime/src/error.rs @@ -30,6 +30,8 @@ pub enum DateTimeFormatterLoadError { Data(DataError), } +impl core::error::Error for DateTimeFormatterLoadError {} + impl From for DateTimeFormatterLoadError { fn from(error: DataError) -> Self { Self::Data(error) @@ -52,6 +54,8 @@ pub struct MismatchedCalendarError { pub date_kind: Option, } +impl core::error::Error for MismatchedCalendarError {} + #[non_exhaustive] #[derive(Debug, PartialEq, Copy, Clone, displaydoc::Display)] /// Error for `TryWriteable` implementations @@ -129,3 +133,5 @@ pub enum DateTimeWriteError { #[displaydoc("Unsupported field {0:?}")] UnsupportedField(ErrorField), } + +impl core::error::Error for DateTimeWriteError {} diff --git a/components/datetime/src/neo_serde.rs b/components/datetime/src/neo_serde.rs index 6898e9f8752..70c1330c476 100644 --- a/components/datetime/src/neo_serde.rs +++ b/components/datetime/src/neo_serde.rs @@ -34,6 +34,8 @@ pub enum CompositeFieldSetSerdeError { InvalidFields, } +impl core::error::Error for CompositeFieldSetSerdeError {} + /// 🚧 \[Experimental\] A type corresponding to [`CompositeFieldSet`] that implements /// [`serde::Serialize`] and [`serde::Deserialize`]. /// diff --git a/components/datetime/src/options/mod.rs b/components/datetime/src/options/mod.rs index e601d9400c7..c34796ffa64 100644 --- a/components/datetime/src/options/mod.rs +++ b/components/datetime/src/options/mod.rs @@ -521,6 +521,8 @@ pub enum FractionalSecondError { OutOfRange, } +impl core::error::Error for FractionalSecondError {} + impl From for u8 { fn from(value: FractionalSecondDigits) -> u8 { use FractionalSecondDigits::*; diff --git a/components/datetime/src/pattern/mod.rs b/components/datetime/src/pattern/mod.rs index 996597fe3d9..7d92512209f 100644 --- a/components/datetime/src/pattern/mod.rs +++ b/components/datetime/src/pattern/mod.rs @@ -89,3 +89,5 @@ pub enum PatternLoadError { #[displaydoc("Problem loading data for field {1:?}: {0}")] Data(icu_provider::DataError, ErrorField), } + +impl core::error::Error for PatternLoadError {} diff --git a/components/datetime/src/scaffold/names_storage.rs b/components/datetime/src/scaffold/names_storage.rs index bcc9fca801c..2ca8c144c9d 100644 --- a/components/datetime/src/scaffold/names_storage.rs +++ b/components/datetime/src/scaffold/names_storage.rs @@ -76,13 +76,17 @@ impl_holder_trait!(tz::MzPeriodV1Marker); /// An error returned by [`MaybePayload`]. #[allow(missing_docs)] -#[derive(Debug)] +#[derive(Debug, displaydoc::Display)] #[non_exhaustive] pub enum MaybePayloadError { + /// TODO TypeTooSpecific, + /// TODO ConflictingField, } +impl core::error::Error for MaybePayloadError {} + impl MaybePayloadError { pub(crate) fn into_load_error(self, error_field: ErrorField) -> PatternLoadError { match self { diff --git a/components/experimental/src/compactdecimal/error.rs b/components/experimental/src/compactdecimal/error.rs index ddeed316d56..fd48648e01e 100644 --- a/components/experimental/src/compactdecimal/error.rs +++ b/components/experimental/src/compactdecimal/error.rs @@ -17,3 +17,5 @@ pub struct ExponentError { /// The magnitude of the number being formatted. pub(crate) log10_type: i16, } + +impl core::error::Error for ExponentError {} diff --git a/components/experimental/src/duration/validated_options.rs b/components/experimental/src/duration/validated_options.rs index 3c0438147df..60337fea275 100644 --- a/components/experimental/src/duration/validated_options.rs +++ b/components/experimental/src/duration/validated_options.rs @@ -81,6 +81,8 @@ pub enum DurationFormatterOptionsError { FractionalDigitsOutOfRange, } +impl core::error::Error for DurationFormatterOptionsError {} + impl ValidatedDurationFormatterOptions { pub fn validate( value: DurationFormatterOptions, diff --git a/components/experimental/src/personnames/api.rs b/components/experimental/src/personnames/api.rs index 80ab15f2894..f0f3abb9eed 100644 --- a/components/experimental/src/personnames/api.rs +++ b/components/experimental/src/personnames/api.rs @@ -49,6 +49,8 @@ pub enum PersonNamesFormatterError { Pattern(icu_pattern::Error), } +impl core::error::Error for PersonNamesFormatterError {} + impl From for PersonNamesFormatterError { fn from(e: DataError) -> Self { PersonNamesFormatterError::Data(e) diff --git a/components/experimental/src/units/ratio.rs b/components/experimental/src/units/ratio.rs index 5320d289df5..213ae74d623 100644 --- a/components/experimental/src/units/ratio.rs +++ b/components/experimental/src/units/ratio.rs @@ -67,6 +67,8 @@ pub enum RatioFromStrError { ParsingBigIntError(num_bigint::ParseBigIntError), } +impl core::error::Error for RatioFromStrError {} + impl IcuRatio { /// Creates a new `IcuRatio` from the given numerator and denominator. pub fn from_big_ints(numerator: BigInt, denominator: BigInt) -> Self { diff --git a/components/locale_core/src/preferences/extensions/unicode/errors.rs b/components/locale_core/src/preferences/extensions/unicode/errors.rs index 343ca5cd6fc..a2ade92d6f2 100644 --- a/components/locale_core/src/preferences/extensions/unicode/errors.rs +++ b/components/locale_core/src/preferences/extensions/unicode/errors.rs @@ -11,3 +11,5 @@ pub enum PreferencesParseError { /// The given keyword value is not a valid preference variant. InvalidKeywordValue, } + +impl core::error::Error for PreferencesParseError {} diff --git a/components/plurals/src/operands.rs b/components/plurals/src/operands.rs index 301beb3a7e2..daf72fcea98 100644 --- a/components/plurals/src/operands.rs +++ b/components/plurals/src/operands.rs @@ -115,6 +115,9 @@ pub enum OperandsError { Invalid, } +#[cfg(feature = "datagen")] +impl core::error::Error for OperandsError {} + #[cfg(feature = "datagen")] impl From for OperandsError { fn from(_: core::num::ParseIntError) -> Self { diff --git a/components/timezone/src/ixdtf.rs b/components/timezone/src/ixdtf.rs index d087f4e8105..569929a8b82 100644 --- a/components/timezone/src/ixdtf.rs +++ b/components/timezone/src/ixdtf.rs @@ -69,6 +69,8 @@ pub enum ParseError { RequiresCalculation, } +impl core::error::Error for ParseError {} + impl From for ParseError { fn from(value: IxdtfParseError) -> Self { Self::Syntax(value) diff --git a/provider/source/src/decimal/decimal_pattern.rs b/provider/source/src/decimal/decimal_pattern.rs index 8405c303515..d3f14bfff5d 100644 --- a/provider/source/src/decimal/decimal_pattern.rs +++ b/provider/source/src/decimal/decimal_pattern.rs @@ -20,8 +20,6 @@ pub(crate) enum Error { UnknownPatternBody(String), } -impl std::error::Error for Error {} - /// Representation of a UTS-35 number subpattern (part of a number pattern between ';'s). #[derive(Debug, PartialEq)] pub(crate) struct DecimalSubPattern { diff --git a/utils/calendrical_calculations/src/error.rs b/utils/calendrical_calculations/src/error.rs index b98edfd6cee..657d5113121 100644 --- a/utils/calendrical_calculations/src/error.rs +++ b/utils/calendrical_calculations/src/error.rs @@ -25,3 +25,5 @@ pub enum LocationOutOfBoundsError { #[displaydoc("Offset {0} outside bounds of {1} to {2}")] Offset(f64, f64, f64), } + +impl core::error::Error for LocationOutOfBoundsError {} diff --git a/utils/calendrical_calculations/src/helpers.rs b/utils/calendrical_calculations/src/helpers.rs index 20d3b4bc2bc..437cc0ce418 100644 --- a/utils/calendrical_calculations/src/helpers.rs +++ b/utils/calendrical_calculations/src/helpers.rs @@ -282,7 +282,7 @@ fn test_invert_angular() { } /// Error returned when casting from an i32 -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, displaydoc::Display)] #[allow(clippy::exhaustive_enums)] // enum is specific to function and has a closed set of possible values pub enum I32CastError { /// Less than i32::MIN @@ -291,6 +291,8 @@ pub enum I32CastError { AboveMax, } +impl core::error::Error for I32CastError {} + impl I32CastError { pub(crate) const fn saturate(self) -> i32 { match self { diff --git a/utils/ixdtf/src/error.rs b/utils/ixdtf/src/error.rs index f97d4f052d3..0efafdfbe74 100644 --- a/utils/ixdtf/src/error.rs +++ b/utils/ixdtf/src/error.rs @@ -106,6 +106,8 @@ pub enum ParseError { TimeDurationDesignator, } +impl core::error::Error for ParseError {} + impl ParseError { pub(crate) fn abrupt_end(location: &'static str) -> Self { ParseError::AbruptEnd { location } diff --git a/utils/zerotrie/src/error.rs b/utils/zerotrie/src/error.rs index 42dbc8b1599..9ef5b86e19b 100644 --- a/utils/zerotrie/src/error.rs +++ b/utils/zerotrie/src/error.rs @@ -21,3 +21,5 @@ pub enum ZeroTrieBuildError { #[displaydoc("Mixed-case data added to case-insensitive trie")] MixedCase, } + +impl core::error::Error for ZeroTrieBuildError {} diff --git a/utils/zerovec/src/varzerovec/error.rs b/utils/zerovec/src/varzerovec/error.rs index 66fa880beb6..b099285d473 100644 --- a/utils/zerovec/src/varzerovec/error.rs +++ b/utils/zerovec/src/varzerovec/error.rs @@ -2,10 +2,23 @@ // called LICENSE at the top level of the ICU4X source tree // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). +use core::fmt::Display; + #[derive(Debug)] pub enum VarZeroVecFormatError { /// The byte buffer was not in the appropriate format for VarZeroVec. Metadata, - #[allow(dead_code)] + /// One of the values could not be decoded. Values(crate::ule::UleError), } + +impl core::error::Error for VarZeroVecFormatError {} + +impl Display for VarZeroVecFormatError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + Self::Metadata => write!(f, "VarZeroVecFormatError: metadata"), + Self::Values(e) => write!(f, "VarZeroVecFormatError: {e}"), + } + } +}