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

Re: [?] echoe acts like an exception inside :catch and :finally blocks

Expand Messages
  • Tony Mechelynck
    ... exception). Depending on where the error happens, it may cause an abort of whatever it is that it is wrapped in. In the present case, the Echoe exception
    Message 1 of 4 , Jun 2, 2011
    • 0 Attachment
      On 02/06/11 23:27, Bram Moolenaar wrote:
      >
      > ZyX wrote:
      >
      >> Is this expected:
      >> try
      >> throw 'Throw'
      >> catch
      >> echoe 'Echoe'
      >> echom 'Echom'
      >> endtry
      >> will show only 'Echoe', but not 'Echom'? I though that «When used
      >> inside a try conditional» refers only to the first section of
      >> `:try...' block, not to `:catch' or `:finally' sections.
      >
      > This indeed looks wrong.
      >

      :echoerr generates an error (which, inside a try block, is handled as an
      exception). Depending on where the error happens, it may cause an abort
      of whatever it is that it is wrapped in.

      In the present case, the "Echoe" exception is not caught, so it will
      propagate outside the try block we see here, to be caught by an outside
      try block if any, or if there isn't, it may (I suppose) propagate as an
      error, causing an abort of some script or function around this try block.


      Best regards,
      Tony.
      --
      Schlattwhapper, n.:
      The window shade that allows itself to be pulled down,
      hesitates for a second, then snaps up in your face.
      -- Rich Hall, "Sniglets"

      --
      You received this message from the "vim_dev" 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
      ... Vimscripts do not normally terminate on errors, and that is the problem here; it does, when it shouldn t. There is no mapping to terminate, no function, no
      Message 2 of 4 , Jun 2, 2011
      • 0 Attachment
        On 3/06/11 9:45 AM, Tony Mechelynck wrote:
        > On 02/06/11 23:27, Bram Moolenaar wrote:
        >> ZyX wrote:
        >>
        >>> Is this expected:
        >>> try
        >>> throw 'Throw'
        >>> catch
        >>> echoe 'Echoe'
        >>> echom 'Echom'
        >>> endtry
        >>> will show only 'Echoe', but not 'Echom'? I though that «When used
        >>> inside a try conditional» refers only to the first section of
        >>> `:try...' block, not to `:catch' or `:finally' sections.
        >>
        >> This indeed looks wrong.
        >>
        >
        > :echoerr generates an error (which, inside a try block, is handled as an
        > exception). Depending on where the error happens, it may cause an abort of
        > whatever it is that it is wrapped in.
        >
        > In the present case, the "Echoe" exception is not caught, so it will
        > propagate outside the try block we see here, to be caught by an
        > outside try block if any, or if there isn't, it may (I suppose)
        > propagate as an error, causing an abort of some script or function
        > around this try block.

        Vimscripts do not normally terminate on errors, and that is the problem
        here; it does, when it shouldn't. There is no mapping to terminate, no
        function, no surrounding try/catch block into which to propagate the
        error. It should just be ignored and the script continue, just as if you
        issued the echoe followed the the echom on the commandline.

        Ben.



        --
        You received this message from the "vim_dev" 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.