Loading ...
Sorry, an error occurred while loading the content.

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

Expand Messages
  • howard Schwartz
    ... Actually the documentation does describe, in detail, the rules for handling errors, exceptions, and interrupts -- if the author of a script encloses it in
    Message 1 of 8 , Mar 31, 2011
    • 0 Attachment
      > However none of you answered,
      > anywhere in the available documentation?
      > Not just mentioned in passing by an example!

      > Where are the rules for this detailed?

      Actually the documentation does describe, in detail, the rules for handling
      errors, exceptions, and interrupts -- if the author of a script encloses it in
      a ``try'' block. You can find these explanations in the document eval.txt in
      Section 8 ``Exception Handling''. You can also use help commands to locate
      descriptionfor the ``catch'' ``throw'' and ``finally'' commands within
      ``try'' and ``endtry'' blocks.

      I had to deal with this recently myself when I wrote a few scripts,.
      Frankly, I found these rules unnecessarily complex and, well, arcane compared
      to error handling in other script languages (e.g., unix shells).

      Vim provides a set of rules for the Author of a script to deal with errors,
      should he or she choose to do so. However, if the author does not use the
      ``try'' mechanism - I fear errors are handled -well - however the developers
      happened to handle each particular error. Generally, error messages are
      displayed and some action may or may not be taken.

      --
      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
    • Ben Schmidt
      ... French grammar is pretty regular compared to some languages! ;-) I think the answer is that because error checking depends on the context, it is documented
      Message 2 of 8 , Apr 1, 2011
      • 0 Attachment
        > However none of you answered,
        > >> Are these kinds of exception rules spelled out explicitly
        > >> anywhere in the available documentation?
        > >> Not just mentioned in passing by an example!
        >
        > >> Where are the rules for this detailed?
        >
        > Or is this an impossible task, since the rules of vim
        > are not regular, but an ad hoc collection?
        > (like French grammar. :-) )

        French grammar is pretty regular compared to some languages! ;-)

        I think the answer is that because error checking depends on the
        context, it is documented at commands which change the error handling,
        not as a set of overarching rules. So you will find details about error
        handling while mappings are running somewhere near the :map command, and
        how it works within :try blocks at the :try command, and how it works
        while executing :global at that command, somewhere near :function the
        abort modifier is explained, etc..

        I guess the overarching rule, which I don't know if it's documented
        anywhere, is that the way errors are handled depends on the 'enclosing
        context' or something like that.

        And Vim scripts, if just sourced, work just like running the commands
        one after the other at the commandline, i.e. the next command is simply
        typed in and executed regardless of the errors of the previous one. I
        think that is in the docs somewhere, but no idea where....

        So, yes, I guess in a sense that's a "the rules are not regular, but
        they ARE documented (all over the place)."

        Does that come close to answering your question?

        Ben.



        --
        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
      Your message has been successfully submitted and would be delivered to recipients shortly.