Viml exceptions: Difference between revisions
From wikinotes
No edit summary |
(→Throw) |
||
Line 31: | Line 31: | ||
endtry | endtry | ||
</source> | </source> | ||
Some common exceptions: | |||
<syntaxhighlight lang="vim"> | |||
E:473 " internal error | |||
E:570 " internal error: {function} | |||
</syntaxhighlight> | |||
</blockquote><!-- throw --> | </blockquote><!-- throw --> | ||
Revision as of 21:04, 7 January 2023
Documentation
: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