unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Spencer Baugh <sbaugh@janestreet.com>, 65897@debbugs.gnu.org
Subject: bug#65897: 29.1.50; Debugging errors surfaced through emacsclient is hard
Date: Mon, 18 Sep 2023 10:00:42 -0400	[thread overview]
Message-ID: <jwv4jjrh9ly.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <83msxols9n.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 14 Sep 2023 17:54:28 +0300")

>> Toy example:
>> 1. emacs -Q
>> 2. (server-start)
>> 3. (add-hook 'before-make-frame-hook (lambda () (error "frame hook error")))
>> 4. emacsclient -c
>> 
>> The output of emacsclient is:
>> 
>> Waiting for Emacs...
>> *ERROR*: frame hook error
>> 
>> That's all, there is no way to get more information about the error that
>> happened.
>> 
>> Ideally, when emacsclient encounters an error and debug-on-error is
>> non-nil, it should cause Emacs to enter the debugger.
>
> I'm not sure we can allow entering the debugger from server-execute.
> That function is documented as being called from timers and process
> filters, so entering the debugger might be unsafe.

AFAIK it is perfectly safe to drop into the debugger when running timers
and process-filters.  I believe the reason why this doesn't happen here is
because of the `condition-case` used to grab the error and send it to
Emacsclient's output.  See patch below.

We could also offer a way to grab the backtrace and send it over to
Emacsclient's output.


        Stefan


diff --git a/lisp/server.el b/lisp/server.el
index 10f15598221..2536a9c6591 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -1175,7 +1175,7 @@ server-process-filter
     (when prev
       (setq string (concat prev string))
       (process-put proc 'previous-string nil)))
-  (condition-case err
+  (condition-case-unless-debug err
       (progn
 	(server-add-client proc)
 	;; Send our pid






      reply	other threads:[~2023-09-18 14:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-12 19:42 bug#65897: 29.1.50; Debugging errors surfaced through emacsclient is hard Spencer Baugh
2023-09-14 14:54 ` Eli Zaretskii
2023-09-18 14:00   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv4jjrh9ly.fsf-monnier+emacs@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=65897@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=sbaugh@janestreet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).