semantic_versions/
error.rs1use std::fmt;
2
3#[derive(Debug, Clone, PartialEq, Eq)]
5pub enum Error {
6 TooLong,
8 InvalidVersion(String),
10 TooLarge(String),
12 InvalidRange(String),
14}
15
16impl fmt::Display for Error {
17 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18 match self {
19 Error::TooLong => write!(f, "input is longer than {} characters", crate::MAX_LENGTH),
20 Error::InvalidVersion(s) => write!(f, "invalid version: {s}"),
21 Error::TooLarge(s) => write!(f, "numeric identifier is too large: {s}"),
22 Error::InvalidRange(s) => write!(f, "invalid range: {s}"),
23 }
24 }
25}
26
27impl std::error::Error for Error {}