From 47bfa4cbb10218441a33fad8d3b8a36211a02b8d Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Tue, 21 Nov 2023 09:47:15 +0100 Subject: [PATCH 1/2] expose `StringMatcherParseError` --- crates/rattler_conda_types/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/rattler_conda_types/src/lib.rs b/crates/rattler_conda_types/src/lib.rs index d58e561fa..a5a290f2b 100644 --- a/crates/rattler_conda_types/src/lib.rs +++ b/crates/rattler_conda_types/src/lib.rs @@ -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}; From f8bf86c86a842fa5b4b41b51e95e4913c16697ce Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Tue, 21 Nov 2023 09:50:31 +0100 Subject: [PATCH 2/2] add docs --- .../rattler_conda_types/src/match_spec/matcher.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/rattler_conda_types/src/match_spec/matcher.rs b/crates/rattler_conda_types/src/match_spec/matcher.rs index 2bb9ddef2..665a31ce9 100644 --- a/crates/rattler_conda_types/src/match_spec/matcher.rs +++ b/crates/rattler_conda_types/src/match_spec/matcher.rs @@ -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 {