There are several wordings for this depending on what programming languages you are used to, but none of them turned up results for me. Also, neither help abort()
nor help raise()
nor help throw()
gave me anything.
How would you explicitly throw an error? How would you explicitly raise an error? How would you explicitly abort?
I have in the past just written my errormessage directly, which is of course invalid code and raises an error, but I'd prefer to be clear about what I'm doing here.
function may_fail() abort
let l:message = system('something')
if v:shell_error
there was a problem with something <- can I use an actual abort() or something here?
endif
endfunction
:h throw-catch
?:h throw
was what I needed, but normally for vimscript questions I'm supposed to add () to find functions.throw
is an Ex command not a function. :) The magic string for those is the:
prefix rather than the()
suffix::h :throw
.:helpgrep
or 2) look for it in both:h function-list
and:h ex-cmd-index
.