Better maktaba#ensure#Passes error messages
- Dominant language
- Vim Script
- Stars
- 588
- Forks
- 41
- PR merge metrics
- No merged PRs in 30d
Description
Currently, `maktaba#ensure#Passes` has no way to pass a custom message in, and can only every give you the very vague message `E605: Exception not caught: ERROR(BadValue): SOMEVALUE failed to pass predicate`. I'd probably never use that as-is since the error is next to worthless.
We should add support for passing in a custom message and/or change it to have a better message by default.
The ideal approach in terms of code readability and clear error message would be to just to pass a literal expression in as a string (`maktaba#ensure#Passes({expr})`) and eval it:
``` VimL
call maktaba#ensure#Passes('a:startline >= 1')
```
`ERROR(BadValue): Condition 'a:startline >= 1' failed`
But the variables won't be evaluated in the right scope. We could at least detect and optimize the common case of:
``` VimL
call maktaba#ensure#Passes(a:startline, maktaba#function#FromExpr('a:1 >= 1'))
```
to automatically report the literal expression that failed: `ERROR(BadValue): Condition 'a:1 >= 1' failed. a:1 was 0`. The `a:1` is a little bit cryptic, but still better than `ERROR(BadValue): 0 failed to pass predicate`.
Contributor guide
Assessment
This issue has not been assessed yet.