Skip to content

Conversation

@Dym03
Copy link
Contributor

@Dym03 Dym03 commented Oct 22, 2025

Fixes #166
Initial proposal of the restructure of the PatterError, inspired by code proposed in Issue #166.
Added thiserror crate for the ease of work with the error messages, if this would be a problem please let me know.
Had to set version, due to rustc 1.63 used, because latest versions require rustc 1.68.

Also while coding wondered if maybe merging the newly created enum with the PatternError wouldn't be cleaner, but not sure. Showcase below

pub enum PatternError {
    /// Wildcard should be only `*` or `**`
    #[error("Patter error at position {pos}: wildcards are either regular `*` or recursive `**` ")]
    InvalidWildcards {pos: usize},
    ...
}

@Dym03 Dym03 force-pushed the PatternErrorTypes branch 4 times, most recently from 1ef8c5d to 0974796 Compare October 22, 2025 19:56
@tgross35 tgross35 added this to the 1.0 milestone Oct 22, 2025
Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added thiserror crate for the ease of work with the error messages, if this would be a problem please let me know. Had to set version, due to rustc 1.63 used, because latest versions require rustc 1.68.

It's not a problem per se, but I think we may as well avoid the extra dependencies here. All we need is the Display impl, which is only a few extra lines to write by hand.

Also while coding wondered if maybe merging the newly created enum with the PatternError wouldn't be cleaner, but not sure. Showcase below

pub enum PatternError {
    /// Wildcard should be only `*` or `**`
    #[error("Patter error at position {pos}: wildcards are either regular `*` or recursive `**` ")]
    InvalidWildcards {pos: usize},
    ...
}

This crossed my mind as well. Since pos is common to all error kinds, I think the current structure is okay. But I would remove the Eq and Copy traits so we have more flexibility adding fields to the enum in the future.

Could you also make PatternError non_exhaustive?

@Dym03 Dym03 force-pushed the PatternErrorTypes branch 2 times, most recently from 6449305 to 7db8619 Compare October 24, 2025 15:21
Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks pretty good with the two small nits here. Unfortunately we can't merge this right away though; this is of course a breaking change, so we need to wait on some decisions about how to handle 1.0 first.

Cargo.toml Outdated
Comment on lines 16 to 17
tempfile = "3"
doc-comment = "0.3"
doc-comment = "0.3"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing trailing newline (changes to this file can just be dropped)

src/lib.rs Outdated
Comment on lines 534 to 540
PatternErrorKind::InvalidWildcards => {
"Wildcards are either regular `*` or recursive `**`"
}
PatternErrorKind::InvalidRecursiveWildcards => {
"Recursive wildcards must form a single path component"
}
PatternErrorKind::InvalidRange => "Invalid range pattern",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error strings usually start with a lowercase letter

@Dym03 Dym03 force-pushed the PatternErrorTypes branch from 7db8619 to 50ad0f1 Compare October 25, 2025 01:54
@Dym03
Copy link
Contributor Author

Dym03 commented Oct 25, 2025

Sure thing, thanks for the feedback. I will try to work on some other things that could bring the glob closer to 1.0 :)

@Dym03 Dym03 force-pushed the PatternErrorTypes branch from 41b0ddb to 50ad0f1 Compare October 25, 2025 15:19
@Dym03 Dym03 force-pushed the PatternErrorTypes branch from 50ad0f1 to 759ed3a Compare October 25, 2025 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[1.0] Restructure PatternError

2 participants