help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: trapping process filter error in a thread


From: Felix Dietrich
Subject: Re: trapping process filter error in a thread
Date: Sun, 10 Apr 2022 10:58:21 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

Thien-Thi Nguyen <ttn@gnuvola.org> writes:

> () Felix Dietrich <felix.dietrich@sperrhaken.name>
> () Thu, 24 Mar 2022 03:33:50 +0100
>
> I think this tells us that error handing wrt threads are as if
> they were invoked as a (top-level) command.

With regard to process filters, I would presume.  They run
asynchronously outside the context of whatever code you told Emacs to
execute whenever Emacs is idle or told to accept process input.  It
would be awkward and rather tedious if you had to be aware not only of
the errors your code could signal but also of all the errors any
potentially running process filter might produce – although in your case
and your use of the url library you kind of have to.  In threads, you
should be able to handle clean-up and errors just as you would do
normally: with ‘unwind-protect’ and ‘condition-case’.  (Though, as I had
mentioned, I have not programmed with threads in Emacs, yet; I just
imagine that this is how it works.)


> I have managed to adapt your code fragment to produce a bad.el
> (attached here):
>
>      (throw (car data) (list (cdr data)
>                              context)))))
>
> Curiously, there is ‘no-catch’ in the CAR of ‘var’ contents, but
> i was not able to find any mention of it in the Elisp reference
> manual.

I donʼt understand what you intended with that ‘throw’, but ‘no-catch’
is mentioned under “Nonlocal Exits” as well as in the elisp reference
manualʼs index.  It means that you are missing an accompanying ‘catch’
to your ‘throw’.  Also: in Emacs you ‘signal’ errors; you donʼt throw
them.

    (info "(elisp) Catch and Throw")  [1]
    (info "(elisp) Signaling Errors") [2]

Both are subsections of:

    (info "(elisp) Nonlocal Exits")   [3]


Footnotes:
[1]  
<https://www.gnu.org/software/emacs/manual/html_node/elisp/Catch-and-Throw.html>

[2]  
<https://www.gnu.org/software/emacs/manual/html_node/elisp/Signaling-Errors.html>

[3]  
<https://www.gnu.org/software/emacs/manual/html_node/elisp/Nonlocal-Exits.html>


-- 
Felix Dietrich



reply via email to

[Prev in Thread] Current Thread [Next in Thread]