vim-maktaba icon indicating copy to clipboard operation
vim-maktaba copied to clipboard

Better maktaba#ensure#Passes error messages

Open dbarnett opened this issue 11 years ago • 0 comments

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:

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:

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.

dbarnett avatar Aug 29 '14 21:08 dbarnett