1use thiserror::Error;
2
3#[derive(Error, Debug, Clone, PartialEq, Eq)]
5pub enum SemverError {
6 #[error("Invalid version string \"{0}\"")]
7 InvalidVersion(String),
8
9 #[error("Invalid version string \"{version}\"{context}")]
10 InvalidVersionWithContext { version: String, context: String },
11
12 #[error("Invalid operator \"{0}\", expected one of: =, ==, <, <=, >, >=, !=, <>")]
13 InvalidOperator(String),
14
15 #[error("Invalid stability \"{0}\", expected one of: stable, RC, beta, alpha, dev")]
16 InvalidStability(String),
17
18 #[error("Could not parse version constraint {0}: {1}")]
19 ConstraintParseFailed(String, String),
20
21 #[error("Empty constraint string")]
22 EmptyConstraint,
23}
24
25pub type Result<T> = std::result::Result<T, SemverError>;