imp: improve bad regexp error message
Eg '(?:foo)' is not malformed, it's just not supported. https://hledger.org/hledger.html#hledgers-regular-expressions
This commit is contained in:
parent
fa8d223858
commit
d19b353bfb
@ -817,7 +817,7 @@ makeHledgerClassyLenses ''ReportSpec
|
||||
-- >>> _rsQuery <$> setEither querystring ["assets"] defreportspec
|
||||
-- Right (Acct (RegexpCI "assets"))
|
||||
-- >>> _rsQuery <$> setEither querystring ["(assets"] defreportspec
|
||||
-- Left "This regular expression is malformed, please correct it:\n(assets"
|
||||
-- Left "This regular expression is invalid or unsupported, please correct it:\n(assets"
|
||||
-- >>> _rsQuery $ set querystring ["assets"] defreportspec
|
||||
-- Acct (RegexpCI "assets")
|
||||
-- >>> _rsQuery $ set querystring ["(assets"] defreportspec
|
||||
|
||||
@ -136,7 +136,7 @@ toRegexCI = memo $ \s -> mkRegexErr s (RegexpCI s <$> makeRegexOptsM defaultComp
|
||||
-- | Make a nice error message for a regexp error.
|
||||
mkRegexErr :: Text -> Maybe a -> Either RegexError a
|
||||
mkRegexErr s = maybe (Left errmsg) Right
|
||||
where errmsg = T.unpack $ "This regular expression is malformed, please correct it:\n" <> s
|
||||
where errmsg = T.unpack $ "This regular expression is invalid or unsupported, please correct it:\n" <> s
|
||||
|
||||
-- Convert a Regexp string to a compiled Regex, throw an error
|
||||
toRegex' :: Text -> Regexp
|
||||
|
||||
@ -268,7 +268,7 @@ hledger: Error: /Users/simon/src/hledger/hledger/test/errors/./parseable-regexps
|
||||
3 | alias /(/ = a
|
||||
| ^
|
||||
|
||||
This regular expression is malformed, please correct it:
|
||||
This regular expression is invalid or unsupported, please correct it:
|
||||
(
|
||||
```
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ $$$ hledger check -f parseable-regexps.j
|
||||
3 \| alias \/\(\/ = a
|
||||
\| \^
|
||||
|
||||
This regular expression is malformed, please correct it:
|
||||
This regular expression is invalid or unsupported, please correct it:
|
||||
\(
|
||||
|
||||
/
|
||||
|
||||
@ -130,7 +130,7 @@ $ hledger -f - print expr:"not tag:transactiontag=B"
|
||||
# ** 9. Having parentheses directly follow 'not' sees 'not' as part of a query.
|
||||
$ hledger -f - print expr:"not(tag:transactiontag=B)"
|
||||
>2
|
||||
hledger: Error: This regular expression is malformed, please correct it:
|
||||
hledger: Error: This regular expression is invalid or unsupported, please correct it:
|
||||
not(tag:transactiontag=B
|
||||
>=1
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user