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

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

bug#24617: 26.0.50; Handlers in `condition-case' should have programmati


From: Helmut Eller
Subject: bug#24617: 26.0.50; Handlers in `condition-case' should have programmatic access to the backtrace
Date: Wed, 05 Oct 2016 08:16:46 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

On Tue, Oct 04 2016, Philipp Stephani wrote:

> Currently a handler in a `condition-case' form doesn't have access to
> the backtrace that was active when the signal was raised.  This makes
> many useful things impossible, such as re-raising signals or returning
> the backtrace to emacsclient.  I suggest either adding true exception
> objects (storing the error symbol, data, and backtrace), or at least
> providing a dynamic variable with the current backtrace.

First, you can copy the backtrace in a signal-hook-function and store it
in global variable.

Second, unconditionally copying the backtrace would be expensive and
would still not allow access to local variables in stack frames or the
value of dynamic variables at the point where the error was signalled
Just because Java or Python do that doesn't make it a great idea.

Third, the solution to this problem in Common Lisp is the HANDLER-CASE
macro which is similar to condition-case but the error handlers are
executed without unwinding the stack.  That doesn't require any copying
and gives full access to the stack. (Again, can be emulated with a
signal-hook-function.)  Of course, that approach can't be used to handle
things like stack overflow or only if done very carefully.

Helmut







reply via email to

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