ripgrep
ripgrep copied to clipboard
improve error messages when -f flag fails
For example:
$ rg -e foo -f src/search_stream.rs
Error parsing regex near 'fer.|*/|z{' at character offset 213: Invalid application of repetition operator to: '(?u:f)(?u:o)(?u:o)|(?u:/)*(?u:!)|(?u:T)(?u:h)(?u:e)
Aside from the badly formatted regex error message (see #395), the error message should show the file path and probably also the line number at which the error occurred.
let me see what I can do.
@BurntSushi I submitted a PR to address this issue. It also tries to avoid the problem with the AST dump (issue https://github.com/BurntSushi/ripgrep/issues/395).
I have one question. Were you thinking about reporting the file path and line number where the error occurred in regex?
I have one question. Were you thinking about reporting the file path and line number where the error occurred in regex?
Probably not. I could maybe see a case for pushing the line number reporting into the regex crate, but certainly not the file path.
Got it. Thanks!
looks like you can close this issue due to rust-lang/regex#396
I am lurking around the repo as a happy user of ripgrep - thanks for the awesome project
@petr-tik Thanks for the kind words, but this is definitely not fixed yet. For example:
$ cat /tmp/patterns
foo
bar(wat
quux
$ rg -f /tmp/patterns
regex parse error:
foo|bar(wat|quux
^
error: unclosed group
There are a few problems here:
- The file path of the pattern file isn't shown in the error message. This is important if you use
-fmultiple times. - There is no line number corresponding to the pattern that failed to parse.
- The error shows all of the patterns in the file given joined with a
|instead of just the pattern that is invalid.
I must have misunderstood the PRs. Only wanted to help you declutter your issues, in case it had been forgotten.
Which files in the repo could be relevant to this?