Skip to content

Commit

Permalink
feat: expose ParseMatchSpecError in rattler_conda_types (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wackyator authored Aug 23, 2023
1 parent 40cccb8 commit 628b83c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/rattler_conda_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub use explicit_environment_spec::{
};
pub use generic_virtual_package::GenericVirtualPackage;
pub use match_spec::matcher::StringMatcher;
pub use match_spec::parse::ParseMatchSpecError;
pub use match_spec::{MatchSpec, NamelessMatchSpec};
pub use no_arch_type::{NoArchKind, NoArchType};
pub use platform::{ParsePlatformError, Platform};
Expand Down
13 changes: 13 additions & 0 deletions crates/rattler_conda_types/src/match_spec/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,54 @@ use std::str::FromStr;
use thiserror::Error;
use url::Url;

/// The type of parse error that occurred when parsing match spec.
#[derive(Debug, Clone, Eq, PartialEq, Error)]
pub enum ParseMatchSpecError {
/// The path or url of the package was invalid
#[error("invalid package path or url")]
InvalidPackagePathOrUrl,

/// Invalid bracket in match spec
#[error("invalid bracket")]
InvalidBracket,

/// Invalid number of colons in match spec
#[error("invalid number of colons")]
InvalidNumberOfColons,

/// Invalid channel provided in match spec
#[error("invalid channel")]
ParseChannelError(#[from] ParseChannelError),

/// Invalid key in match spec
#[error("invalid bracket key: {0}")]
InvalidBracketKey(String),

/// Missing package name in match spec
#[error("missing package name")]
MissingPackageName,

/// Multiple bracket sections in match spec
#[error("multiple bracket sections not allowed")]
MultipleBracketSectionsNotAllowed,

/// Invalid version and build
#[error("Unable to parse version spec: {0}")]
InvalidVersionAndBuild(String),

/// Invalid version spec
#[error("invalid version spec: {0}")]
InvalidVersionSpec(#[from] ParseVersionSpecError),

/// Invalid string matcher
#[error("invalid string matcher: {0}")]
InvalidStringMatcher(#[from] StringMatcherParseError),

/// Invalid build number
#[error("invalid build number: {0}")]
InvalidBuildNumber(#[from] ParseIntError),

/// Unable to parse hash digest from hex
#[error("Unable to parse hash digest from hex")]
InvalidHashDigest,
}
Expand Down

0 comments on commit 628b83c

Please sign in to comment.