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

zbraniecki / icu4x / 11904027177

19 Nov 2024 12:33AM UTC coverage: 75.477% (+0.3%) from 75.174%
11904027177

push

github

web-flow
Move DateTimePattern into pattern module (#5834)

#1317

Also removes `NeoNeverMarker` and fixes #5689

258 of 319 new or added lines in 6 files covered. (80.88%)

6967 existing lines in 278 files now uncovered.

54522 of 72237 relevant lines covered (75.48%)

655305.49 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::Field;
6
use displaydoc::Display;
7
use icu_calendar::{
8
    any_calendar::AnyCalendarKind,
9
    types::{FormattingEra, MonthCode},
10
};
11

12
#[cfg(doc)]
13
use crate::pattern::TypedDateTimeNames;
14
#[cfg(doc)]
15
use icu_calendar::types::YearInfo;
16
#[cfg(doc)]
17
use icu_decimal::FixedDecimalFormatter;
18

19
/// An error from mixing calendar types in a formatter.
UNCOV
20
#[derive(Display, Debug, Copy, Clone, PartialEq)]
×
21
#[displaydoc("DateTimeFormatter for {this_kind} calendar was given a {date_kind:?} calendar")]
×
22
#[non_exhaustive]
23
pub struct MismatchedCalendarError {
24
    /// The calendar kind of the target object (formatter).
25
    pub this_kind: AnyCalendarKind,
×
26
    /// The calendar kind of the input object (date being formatted).
27
    /// Can be `None` if the input calendar was not specified.
28
    pub date_kind: Option<AnyCalendarKind>,
×
29
}
30

31
#[non_exhaustive]
UNCOV
32
#[derive(Debug, PartialEq, Copy, Clone, displaydoc::Display)]
×
33
/// Error for `TryWriteable` implementations
34
pub enum DateTimeWriteError {
35
    /// The [`MonthCode`] of the input is not valid for this calendar.
36
    ///
37
    /// This is guaranteed not to happen for `icu::calendar` inputs, but may happen for custom inputs.
38
    ///
39
    /// The output will contain the raw [`MonthCode`] as a fallback value.
40
    #[displaydoc("Invalid month {0:?}")]
UNCOV
41
    InvalidMonthCode(MonthCode),
×
42
    /// The [`FormattingEra`] of the input is not valid for this calendar.
43
    ///
44
    /// This is guaranteed not to happen for `icu::calendar` inputs, but may happen for custom inputs.
45
    ///
46
    /// The output will contain [`FormattingEra::fallback_name`] as the fallback.
47
    #[displaydoc("Invalid era {0:?}")]
UNCOV
48
    InvalidEra(FormattingEra),
×
49
    /// The [`YearInfo::cyclic`] of the input is not valid for this calendar.
50
    ///
51
    /// This is guaranteed not to happen for `icu::calendar` inputs, but may happen for custom inputs.
52
    ///
53
    /// The output will contain [`YearInfo::extended_year`] as a fallback value.
UNCOV
54
    #[displaydoc("Invalid cyclic year {value} (maximum {max})")]
×
55
    InvalidCyclicYear {
56
        /// Value
UNCOV
57
        value: usize,
×
58
        /// Max
59
        max: usize,
×
60
    },
61

62
    /// The [`FixedDecimalFormatter`] has not been loaded.
63
    ///
64
    /// This *only* happens if the formatter has been created using
65
    /// [`TypedDateTimeNames::with_pattern`], the pattern requires decimal
66
    /// formatting, and the decimal formatter was not loaded.
67
    ///
68
    /// The output will contain fallback values using Latin numerals.
69
    #[displaydoc("FixedDecimalFormatter not loaded")]
70
    FixedDecimalFormatterNotLoaded,
71
    /// The localized names for a field have not been loaded.
72
    ///
73
    /// This *only* happens if the formatter has been created using
74
    /// [`TypedDateTimeNames::with_pattern`], and the pattern requires names
75
    /// that were not loaded.
76
    ///
77
    /// The output will contain fallback values using field identifiers (such as `tue` for `IsoWeekday::Tuesday`,
78
    /// `M02` for month 2, etc.).
79
    #[displaydoc("Names for {0:?} not loaded")]
UNCOV
80
    NamesNotLoaded(Field),
×
81
    /// An input field (such as "hour" or "month") is missing.
82
    ///
83
    /// This *only* happens if the formatter has been created using
84
    /// [`TypedDateTimeNames::with_pattern`], and the pattern requires fields
85
    /// that are not returned by the input type.
86
    ///
87
    /// The output will contain the string `{X}` instead, where `X` is the symbol for which the input is missing.
88
    #[displaydoc("Incomplete input, missing value for {0:?}")]
UNCOV
89
    MissingInputField(&'static str),
×
90
    /// Unsupported field
91
    ///
92
    /// This *only* happens if the formatter has been created using
93
    /// [`TypedDateTimeNames::with_pattern`], and the pattern contains unsupported fields.
94
    ///
95
    /// The output will contain the string `{unsupported:X}`, where `X` is the symbol of the unsupported field.
96
    #[displaydoc("Unsupported field {0:?}")]
97
    UnsupportedField(Field),
×
98
}
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

© 2026 Coveralls, Inc