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

25 views
Skip to first unread message

ZyX

unread,
Jun 2, 2011, 12:26:33 PM6/2/11
to vim...@googlegroups.com
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.
signature.asc

Bram Moolenaar

unread,
Jun 2, 2011, 5:27:56 PM6/2/11
to ZyX, vim...@googlegroups.com

ZyX wrote:

This indeed looks wrong.

--
Don't drink and drive. You might hit a bump and spill your beer.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Tony Mechelynck

unread,
Jun 2, 2011, 7:45:26 PM6/2/11
to vim...@googlegroups.com, Bram Moolenaar, ZyX
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"

Ben Schmidt

unread,
Jun 2, 2011, 7:56:07 PM6/2/11
to vim...@googlegroups.com, Tony Mechelynck, Bram Moolenaar, ZyX
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.

Reply all
Reply to author
Forward
0 new messages