Debian Codegraph @

third_party/rust/icu_normalizer/src/error.rs

raw
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 //! Normalizer-specific error
6
7 use displaydoc::Display;
8 use icu_properties::PropertiesError;
9 use icu_provider::DataError;
10
11 /// A list of error outcomes for various operations in this module.
12 ///
13 /// Re-exported as [`Error`](crate::Error).
14 #[derive(Display, Debug)]
15 #[non_exhaustive]
16 pub enum NormalizerError {
17 /// Error coming from the data provider
18 #[displaydoc("{0}")]
19 Data(DataError),
20 /// The data uses a planned but unsupported feature.
21 FutureExtension,
22 /// Data failed manual validation
23 ValidationError,
24 }
25
26 #[cfg(feature = "std")]
27 impl std::error::Error for NormalizerError {}
28
29 impl From<DataError> for NormalizerError {
30 fn from(e: DataError) -> Self {
31 NormalizerError::Data(e)
32 }
33 }
34
35 impl From<PropertiesError> for NormalizerError {
36 fn from(e: PropertiesError) -> Self {
37 match e {
38 PropertiesError::PropDataLoad(d) => NormalizerError::Data(d),
39 _ => unreachable!("Shouldn't have non-Data PropertiesError"),
40 }
41 }
42 }