44 lines
787 B
Rust
44 lines
787 B
Rust
use std::{
|
|
fmt,
|
|
num::{ParseIntError, TryFromIntError},
|
|
};
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub enum Error {
|
|
FromUint,
|
|
Range,
|
|
ParseArch,
|
|
ParseInt,
|
|
ParseGitRev,
|
|
ParsePreRelease,
|
|
ParseSemver,
|
|
ParseVersion,
|
|
TryFromInt,
|
|
}
|
|
|
|
impl fmt::Display for Error {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
write!(f, "{self:?}")
|
|
}
|
|
}
|
|
|
|
impl std::error::Error for Error {}
|
|
|
|
impl From<TryFromIntError> for Error {
|
|
fn from(_value: TryFromIntError) -> Self {
|
|
Self::TryFromInt
|
|
}
|
|
}
|
|
|
|
impl From<ParseIntError> for Error {
|
|
fn from(_value: ParseIntError) -> Self {
|
|
Self::ParseInt
|
|
}
|
|
}
|
|
|
|
impl From<chrono::ParseError> for Error {
|
|
fn from(_value: chrono::ParseError) -> Self {
|
|
Self::ParseGitRev
|
|
}
|
|
}
|