Thursday, March 31, 2011

Re: What is supposed to happen if there is an error in a vim script?

On Thu, March 31, 2011 8:38 am, Rostyslaw Lewyckyj wrote:
> IF vim recognizes an error in a script, what does it do?
> Where are the rules for this detailed?
>
> Suppose that while editing file.foo, I initiate a script
> e.g. :so myscript.vim
> and there is an error
> e.g. the script looks for a non existing pattern in file.foo
> After issuing its error message what is the expected action
> for the general case:
> 1. The script is immediately terminated, returning to the
> invocation point?
> 2. After possibly issuing an error message,
> the script continues trying to execute with its next command.
> In this case as if the search for the pattern had not failed?
>
> Are these kinds of exception rules spelled out explicitly
> anywhere in the available documentation?
> Not just mentioned in passing by an example!
>
> In my simple test case, it appears that 2. is the rule.
> But of course I'm just seemingly poking a black box.

Yes, in general, rule 2 applies. But when writing your script,
you can define otherwise, using e.g. try/catch/finally or the abort
keyword when defining a function.

regards,
Christian

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: