From unknown Fri Sep 05 11:01:52 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#24617 <24617@debbugs.gnu.org> To: bug#24617 <24617@debbugs.gnu.org> Subject: Status: 26.0.50; Handlers in `condition-case' should have programmatic access to the backtrace Reply-To: bug#24617 <24617@debbugs.gnu.org> Date: Fri, 05 Sep 2025 18:01:52 +0000 retitle 24617 26.0.50; Handlers in `condition-case' should have programmati= c access to the backtrace reassign 24617 emacs submitter 24617 Philipp Stephani
This sounds like a great idea!
As an aside, note that these things are not impossible; just tricky.=C2=A0 = You just need to register your own debugger, then in that debugger function= re-throw the error after recording the backtrace.=C2=A0 You also need to i= ncrement num-nonmacro-input-events from the debugger.
Second, unconditionally copying the backtrace would be expensiveAre you sure about that? In languages that are typic= ally far more performance-sensitive (e.g. Java), the backtrace is also copi= ed unconditionally.=C2=A0an= d
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.True, but having the fun= ction names and argument values is better than nothing when debugging the c= ause of a signal.=C2=A0
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.=C2=A0 That doesn't require any co= pying
and gives full access to the stack.That s= ounds like an interesting approach that could be made to solve some common = use cases (e.g. test runners or rethrowing signals).