semver_php/
error.rs

1use thiserror::Error;
2
3/// Errors that can occur when parsing or working with versions and constraints.
4#[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
25/// A specialized Result type for semver operations.
26pub type Result<T> = std::result::Result<T, SemverError>;