Skip to content

Commit

Permalink
missing error impls
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian committed Jan 13, 2025
1 parent 7d90651 commit bdae6c7
Show file tree
Hide file tree
Showing 21 changed files with 63 additions and 5 deletions.
4 changes: 4 additions & 0 deletions components/calendar/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}")]
Expand All @@ -44,6 +46,8 @@ pub struct RangeError {
pub max: i32,
}

impl core::error::Error for RangeError {}

impl From<RangeError> for DateError {
fn from(value: RangeError) -> Self {
let RangeError {
Expand Down
2 changes: 2 additions & 0 deletions components/collections/src/codepointtrie/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
2 changes: 2 additions & 0 deletions components/datetime/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions components/datetime/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ pub enum DateTimeFormatterLoadError {
Data(DataError),
}

impl core::error::Error for DateTimeFormatterLoadError {}

impl From<DataError> for DateTimeFormatterLoadError {
fn from(error: DataError) -> Self {
Self::Data(error)
Expand All @@ -52,6 +54,8 @@ pub struct MismatchedCalendarError {
pub date_kind: Option<AnyCalendarKind>,
}

impl core::error::Error for MismatchedCalendarError {}

#[non_exhaustive]
#[derive(Debug, PartialEq, Copy, Clone, displaydoc::Display)]
/// Error for `TryWriteable` implementations
Expand Down Expand Up @@ -129,3 +133,5 @@ pub enum DateTimeWriteError {
#[displaydoc("Unsupported field {0:?}")]
UnsupportedField(ErrorField),
}

impl core::error::Error for DateTimeWriteError {}
2 changes: 2 additions & 0 deletions components/datetime/src/neo_serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`].
///
Expand Down
2 changes: 2 additions & 0 deletions components/datetime/src/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ pub enum FractionalSecondError {
OutOfRange,
}

impl core::error::Error for FractionalSecondError {}

impl From<FractionalSecondDigits> for u8 {
fn from(value: FractionalSecondDigits) -> u8 {
use FractionalSecondDigits::*;
Expand Down
2 changes: 2 additions & 0 deletions components/datetime/src/pattern/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
6 changes: 5 additions & 1 deletion components/datetime/src/scaffold/names_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions components/experimental/src/compactdecimal/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
2 changes: 2 additions & 0 deletions components/experimental/src/duration/validated_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ pub enum DurationFormatterOptionsError {
FractionalDigitsOutOfRange,
}

impl core::error::Error for DurationFormatterOptionsError {}

impl ValidatedDurationFormatterOptions {
pub fn validate(
value: DurationFormatterOptions,
Expand Down
2 changes: 2 additions & 0 deletions components/experimental/src/personnames/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ pub enum PersonNamesFormatterError {
Pattern(icu_pattern::Error),
}

impl core::error::Error for PersonNamesFormatterError {}

impl From<DataError> for PersonNamesFormatterError {
fn from(e: DataError) -> Self {
PersonNamesFormatterError::Data(e)
Expand Down
2 changes: 2 additions & 0 deletions components/experimental/src/units/ratio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ pub enum PreferencesParseError {
/// The given keyword value is not a valid preference variant.
InvalidKeywordValue,
}

impl core::error::Error for PreferencesParseError {}
3 changes: 3 additions & 0 deletions components/plurals/src/operands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ pub enum OperandsError {
Invalid,
}

#[cfg(feature = "datagen")]
impl core::error::Error for OperandsError {}

#[cfg(feature = "datagen")]
impl From<core::num::ParseIntError> for OperandsError {
fn from(_: core::num::ParseIntError) -> Self {
Expand Down
2 changes: 2 additions & 0 deletions components/timezone/src/ixdtf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ pub enum ParseError {
RequiresCalculation,
}

impl core::error::Error for ParseError {}

impl From<IxdtfParseError> for ParseError {
fn from(value: IxdtfParseError) -> Self {
Self::Syntax(value)
Expand Down
2 changes: 0 additions & 2 deletions provider/source/src/decimal/decimal_pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions utils/calendrical_calculations/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
4 changes: 3 additions & 1 deletion utils/calendrical_calculations/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions utils/ixdtf/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 2 additions & 0 deletions utils/zerotrie/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ pub enum ZeroTrieBuildError {
#[displaydoc("Mixed-case data added to case-insensitive trie")]
MixedCase,
}

impl core::error::Error for ZeroTrieBuildError {}
15 changes: 14 additions & 1 deletion utils/zerovec/src/varzerovec/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}"),
}
}
}

0 comments on commit bdae6c7

Please sign in to comment.