• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zbraniecki / icu4x / 6815798908

09 Nov 2023 05:17PM UTC coverage: 72.607% (-2.4%) from 75.01%
6815798908

push

github

web-flow
Implement `Any/BufferProvider` for some smart pointers (#4255)

Allows storing them as a `Box<dyn Any/BufferProvider>` without using a
wrapper type that implements the trait.

44281 of 60987 relevant lines covered (72.61%)

201375.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/components/datetime/src/error.rs
1
// This file is part of ICU4X. For terms of use, please see the file
2
// called LICENSE at the top level of the ICU4X source tree
3
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
4

5
use crate::fields::FieldSymbol;
6
use crate::input::CalendarError;
7
use crate::pattern::PatternError;
8
use displaydoc::Display;
9
use icu_calendar::any_calendar::AnyCalendarKind;
10
use icu_calendar::types::MonthCode;
11
use icu_decimal::DecimalError;
12
use icu_plurals::PluralsError;
13
use icu_provider::DataError;
14

15
#[cfg(feature = "std")]
16
impl std::error::Error for DateTimeError {}
17

18
/// A list of error outcomes for various operations in this module.
19
///
20
/// Re-exported as [`Error`](crate::Error).
21
#[derive(Display, Debug, Copy, Clone, PartialEq)]
×
22
#[non_exhaustive]
23
pub enum DateTimeError {
24
    /// An error originating from parsing a pattern.
25
    #[displaydoc("{0}")]
×
26
    Pattern(PatternError),
×
27
    /// An error originating from the [`Write`](std::fmt::Write) trait.
28
    #[displaydoc("{0}")]
×
29
    Format(core::fmt::Error),
×
30
    /// An error originating inside of the [data provider](icu_provider).
31
    #[displaydoc("{0}")]
×
32
    Data(DataError),
×
33
    /// An error originating from a missing field in datetime input.
34
    /// TODO: How can we return which field was missing?
35
    #[displaydoc("Missing input field")]
36
    MissingInputField(Option<&'static str>),
×
37
    /// An error originating from skeleton matching.
38
    #[displaydoc("{0}")]
×
39
    #[cfg(feature = "experimental")]
40
    Skeleton(crate::skeleton::SkeletonError),
×
41
    /// An error originating from an unsupported field in a datetime format.
42
    #[displaydoc("Unsupported field: {0:?}")]
43
    UnsupportedField(FieldSymbol),
×
44
    /// An error due to there being no patterns for the given options.
45
    #[displaydoc("Unsupported options")]
46
    UnsupportedOptions,
47
    /// An error originating from [`PluralRules`][icu_plurals::PluralRules].
48
    #[displaydoc("{0}")]
×
49
    PluralRules(PluralsError),
×
50
    /// An error originating from [`DateTimeInput`][crate::input::DateTimeInput].
51
    #[displaydoc("{0}")]
×
52
    DateTimeInput(CalendarError),
×
53
    /// An error originating from a missing weekday symbol in the data.
54
    #[displaydoc("Data file missing weekday symbol for weekday {0}")]
×
55
    MissingWeekdaySymbol(usize),
×
56
    /// An error originating from a missing month symbol in the data.
57
    #[displaydoc("Data file missing month symbol for month code {0}")]
×
58
    MissingMonthSymbol(MonthCode),
×
59
    /// An error while attempting to format the input as a FixedDecimal
60
    #[displaydoc("FixedDecimal")]
61
    FixedDecimal,
62
    /// An error originating from FixedDecimalFormatter
63
    #[displaydoc("{0}")]
×
64
    FixedDecimalFormatter(DecimalError),
×
65
    /// An error from mixing calendar types in [`DateTimeFormatter`](crate::DateTimeFormatter)
66
    #[displaydoc("DateTimeFormatter for {0} calendar was given a {1:?} calendar")]
×
67
    MismatchedAnyCalendar(AnyCalendarKind, Option<AnyCalendarKind>),
×
68
    /// Missing date symbols
69
    #[displaydoc("Missing date symbols")]
70
    MissingDateSymbols,
71
    /// Missing time symbols
72
    #[displaydoc("Missing time symbols")]
73
    MissingTimeSymbols,
74
    /// ordinal_rules must be set for PatternPlurals::MultipleVariants
75
    #[displaydoc("ordinal_rules must be set for PatternPlurals::MultipleVariants")]
76
    MissingOrdinalRules,
77
}
78

79
impl From<PatternError> for DateTimeError {
80
    fn from(e: PatternError) -> Self {
×
81
        DateTimeError::Pattern(e)
×
82
    }
×
83
}
84

85
impl From<DataError> for DateTimeError {
86
    fn from(e: DataError) -> Self {
×
87
        DateTimeError::Data(e)
×
88
    }
×
89
}
90

91
impl From<core::fmt::Error> for DateTimeError {
92
    fn from(e: core::fmt::Error) -> Self {
×
93
        DateTimeError::Format(e)
×
94
    }
×
95
}
96

97
impl From<PluralsError> for DateTimeError {
98
    fn from(e: PluralsError) -> Self {
×
99
        DateTimeError::PluralRules(e)
×
100
    }
×
101
}
102

103
impl From<CalendarError> for DateTimeError {
104
    fn from(e: CalendarError) -> Self {
×
105
        DateTimeError::DateTimeInput(e)
×
106
    }
×
107
}
108

109
impl From<DecimalError> for DateTimeError {
110
    fn from(e: DecimalError) -> Self {
×
111
        DateTimeError::FixedDecimalFormatter(e)
×
112
    }
×
113
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc