Viml exceptions
From wikinotes
Documentation
:h message.txt
(all E### error codes)https://vimhelp.org/message.txt.html#message.txt :help 41.9 (Exceptions) http://vimdoc.sourceforge.net/htmldoc/usr_41.html#41.9 :help error messages http://vimdoc.sourceforge.net/htmldoc/message.html#error-messages
Magic Variables
v:excepton " last raised exception v:throwpoint " where last exception occurred
Throw
Vim does not have exception types. It has error messages.
Careful - vim has several builtin exceptions (E\d+
) you should not throw exceptions that conflict with them. See:help error messages
for details.try throw "E100" catch /E100/ echo "caught E100 error" endtrySome common exceptions:
E:473 " internal error E:570 " internal error: {function}
Try/Catch
try " ... catch /.*/ echo v:exception " most recent exception throw v:exception " re-throw last exception " ... finally " ... endtryIf you want to simply pass any exceptions, you can run a bare try/catch/endtry
try bd blah " produces exception catch endtry