Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose StringMatcherParseError #410

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/rattler_conda_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub use explicit_environment_spec::{
ParseExplicitEnvironmentSpecError, ParsePackageArchiveHashError,
};
pub use generic_virtual_package::GenericVirtualPackage;
pub use match_spec::matcher::StringMatcher;
pub use match_spec::matcher::{StringMatcher, StringMatcherParseError};
pub use match_spec::parse::ParseMatchSpecError;
pub use match_spec::{MatchSpec, NamelessMatchSpec};
pub use no_arch_type::{NoArchKind, NoArchType};
Expand Down
13 changes: 11 additions & 2 deletions crates/rattler_conda_types/src/match_spec/matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,22 @@ impl StringMatcher {
}
}

/// Error when parsing [`StringMatcher`]
#[derive(Debug, Clone, Eq, PartialEq, thiserror::Error)]
pub enum StringMatcherParseError {
/// Could not parse the string as a glob
#[error("invalid glob: {glob}")]
InvalidGlob { glob: String },
InvalidGlob {
/// The invalid glob
glob: String,
},

/// Could not parse the string as a regex
#[error("invalid regex: {regex}")]
InvalidRegex { regex: String },
InvalidRegex {
/// The invalid regex
regex: String,
},
}

impl FromStr for StringMatcher {
Expand Down