obsidian-tasks icon indicating copy to clipboard operation
obsidian-tasks copied to clipboard

Include the problem line in regex error message

Open claremacrae opened this issue 2 years ago • 1 comments

Expected Behavior

When I make a mistake in a regex instruction, I would like to see which instruction is the one that failed.

This is helpful when I have more than one regex in a tasks block, to tell me which is the first one that I got wrong.

Current behaviour

One of the following error messages is written out. None of them includes the problem filter.

                    result.error = `cannot parse regex (${this.fieldName()}); check your leading and trailing slashes for your query`;
                }
            } else {
                result.error = `do not understand query filter (${this.fieldName()})`;
            }
        } else {
            result.error = `do not understand query filter (${this.fieldName()})`;

Steps to reproduce

Write an invalid filter, such as this which has match instead of matches:

path regex match /aaaa/

Which Operating Systems are you using?

  • [ ] Android
  • [ ] iPhone/iPad
  • [ ] Linux
  • [X] macOS
  • [ ] Windows

Obsidian Version

0.15.9

Tasks Plugin Version

1.12.0 pre-release

Checks

  • [X] I have tried it with all other plugins disabled and the error still occurs

claremacrae avatar Aug 17 '22 21:08 claremacrae

Here is an example of the kind of error message about invalid regex patterns shown by the Apply Patterns plugin:

image

The bit that is useful here is 'unterminated group' and the fact that it includes the problem regex pattern itself (which would be useful if the user had multiple regexes in one tasks block).

Assuming it uses the same library, then reviewing its source code to find out how it obtains the description of the error could be very illuminating.

Note: This is now broken out in to separate issue #2129.

claremacrae avatar Aug 31 '22 19:08 claremacrae

Fixed by #2128

claremacrae avatar Jul 14 '23 21:07 claremacrae