Not able to catch exception from readdirex()

10 views
Skip to first unread message

Yegappan Lakshmanan

unread,
Oct 10, 2020, 9:20:38 PM10/10/20
to vim_dev
Hi all,

Using Vim 8.2.1805, an exception thrown by readdirex() is not caught by
a try-catch statement:

try
    let files = "non-existing-dir"->readdirex()
catch
    echo "caught an exception"
endtry

This works in older versions of Vim (8.1.2292).

- Yegappan

Bram Moolenaar

unread,
Oct 11, 2020, 8:22:56 AM10/11/20
to vim...@googlegroups.com, Yegappan Lakshmanan
This uses smsg() instead of semsg(). I'll fix it.

--
Time is money. Especially if you make clocks.

/// 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 ///

Yegappan Lakshmanan

unread,
Oct 11, 2020, 11:29:52 AM10/11/20
to Bram Moolenaar, vim_dev
Hi Bram,

On Sun, Oct 11, 2020 at 5:22 AM Bram Moolenaar <Br...@moolenaar.net> wrote:

Yegappan wrote:

> Using Vim 8.2.1805, an exception thrown by readdirex() is not caught by
> a try-catch statement:
>
> try
>     let files = "non-existing-dir"->readdirex()
> catch
>     echo "caught an exception"
> endtry
>
> This works in older versions of Vim (8.1.2292).

This uses smsg() instead of semsg().  I'll fix it.


Thanks for fixing this. I missed that in the previous versions of Vim it was
throwing a different exception. I thought it was broken by the recent changes
to handle exceptions in Vim9.

Regards,
Yegappan 

Reply all
Reply to author
Forward
0 new messages