Skip to main content

use_compound/
error.rs

1use std::error::Error;
2use std::fmt;
3
4/// Errors returned when constructing compound values.
5#[derive(Clone, Debug, Eq, PartialEq)]
6pub enum CompoundValidationError {
7    /// A primary compound name is empty.
8    EmptyName,
9    /// A common name is empty.
10    EmptyCommonName,
11    /// A systematic name is empty.
12    EmptySystematicName,
13    /// An identifier registry namespace is empty.
14    EmptyIdentifierNamespace,
15    /// An identifier value is empty.
16    EmptyIdentifierValue,
17}
18
19impl fmt::Display for CompoundValidationError {
20    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
21        match self {
22            Self::EmptyName => formatter.write_str("compound name must not be empty"),
23            Self::EmptyCommonName => formatter.write_str("common name must not be empty"),
24            Self::EmptySystematicName => formatter.write_str("systematic name must not be empty"),
25            Self::EmptyIdentifierNamespace => {
26                formatter.write_str("compound identifier namespace must not be empty")
27            },
28            Self::EmptyIdentifierValue => {
29                formatter.write_str("compound identifier value must not be empty")
30            },
31        }
32    }
33}
34
35impl Error for CompoundValidationError {}