GNU bug report logs - #57195
28.1.90; Can error backtrace be preserved upon intercepting with `condition-case'?

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Ihor Radchenko <yantar92@HIDDEN>; dated Sun, 14 Aug 2022 03:49:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 57195 <at> debbugs.gnu.org:


Received: (at 57195) by debbugs.gnu.org; 15 Aug 2022 07:18:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Aug 15 03:18:48 2022
Received: from localhost ([127.0.0.1]:40549 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oNUN6-0007uA-51
	for submit <at> debbugs.gnu.org; Mon, 15 Aug 2022 03:18:48 -0400
Received: from quimby.gnus.org ([95.216.78.240]:56212)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1oNUN4-0007tx-8Y
 for 57195 <at> debbugs.gnu.org; Mon, 15 Aug 2022 03:18:46 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:Date:References:
 In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=fUM+Bs/+SOAZnIpuIKU2LhFpcPRosYqtAorQYchicaA=; b=hdmzHHdFQuY2gi00dqnLXqMoWE
 5b75y22BvI/4A0Z3Zz+plWp3FGnSssILeAV7IpZWGHEhf7AT/kDEq29P/vxDFC2mdIWY/54a5km4e
 WUFyTcuXWYv5RPt4U81sUljlVFygZZHymY5phMtFy5v5t4ZdzFXb+faO+ZXNSmRR8Zes=;
Received: from [84.212.220.105] (helo=joga)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1oNUMw-0004qX-5z; Mon, 15 Aug 2022 09:18:40 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Ihor Radchenko <yantar92@HIDDEN>
Subject: Re: bug#57195: 28.1.90; Can error backtrace be preserved upon
 intercepting with `condition-case'?
In-Reply-To: <87edxj1o3z.fsf@localhost> (Ihor Radchenko's message of "Sun, 14
 Aug 2022 11:49:04 +0800")
References: <87edxj1o3z.fsf@localhost>
X-Now-Playing: Aksak Maboul's _Un Peu De L'Ame Des Bandits_: "Cinema"
Date: Mon, 15 Aug 2022 09:18:37 +0200
Message-ID: <87bksmasaa.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview: Ihor Radchenko <yantar92@HIDDEN> writes: > Is it possible
 to display the original backtrace in the intercepted > condition-case? I
 don't think that's possible, so that's why condition-case-unless-debug exists.
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 57195
Cc: 57195 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Ihor Radchenko <yantar92@HIDDEN> writes:

> Is it possible to display the original backtrace in the intercepted
> condition-case?

I don't think that's possible, so that's why condition-case-unless-debug
exists.





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57195; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 14 Aug 2022 03:48:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Aug 13 23:48:20 2022
Received: from localhost ([127.0.0.1]:35535 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oN4bs-0007eR-6T
	for submit <at> debbugs.gnu.org; Sat, 13 Aug 2022 23:48:20 -0400
Received: from lists.gnu.org ([209.51.188.17]:51152)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yantar92@HIDDEN>) id 1oN4bn-0007e8-4C
 for submit <at> debbugs.gnu.org; Sat, 13 Aug 2022 23:48:18 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:33686)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <yantar92@HIDDEN>)
 id 1oN4bm-0004rg-7N
 for bug-gnu-emacs@HIDDEN; Sat, 13 Aug 2022 23:48:14 -0400
Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]:45775)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <yantar92@HIDDEN>)
 id 1oN4bk-0006rb-2k
 for bug-gnu-emacs@HIDDEN; Sat, 13 Aug 2022 23:48:13 -0400
Received: by mail-pl1-x62b.google.com with SMTP id 13so3825683plo.12
 for <bug-gnu-emacs@HIDDEN>; Sat, 13 Aug 2022 20:48:04 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=mime-version:message-id:date:subject:to:from:from:to:cc;
 bh=oU3hzUKZtHpPGCpc12w8m0pVWgwFlwiRFpUJUZADtyI=;
 b=SeE3n3UviWUEjSrSN2cZUeRoV/uPRJvYS/Pr7BJpWnFi5l6OaM28N4JwBD7Ukp4yZr
 ztm66wRXiLFLggras/hlyp7DU4lVOuDp5kq/RfqeZx5nQq5kMH9rhIu3aZynqpc0YbAr
 tEgpO/oAm36czCfjhWAgH2oAhsDVDcLCCANo6WFGS0zgrSVEX9eUTipwDwihTrRW3qiz
 2AgT9xAmFFS4DrAdtRvnWksk/uUpV+28xf43RtYPl1sAIFs61xj3/w+M9Y/RmhI+Fw9X
 CJ+UFnI2x7/6cRxJ7Em73g4pg2HmIyflSMvKFnsdpKTzbySebykTSpqjRU0WCHarlFk2
 cxYw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=mime-version:message-id:date:subject:to:from:x-gm-message-state
 :from:to:cc;
 bh=oU3hzUKZtHpPGCpc12w8m0pVWgwFlwiRFpUJUZADtyI=;
 b=rYp3k/toDbmerxLxelgwcVJE0dMtM9lKxlWCSYXSpRKL8ZrBvanKOMyUWTxMw6LRvq
 oQIJYGJkfmNa3nJRDI6dPTOgUMdFyMvrb4yiLeCBBGqgDLpv7apOfLpe3vdZyzFb9LD7
 s0LrJY72u+NMt8fx/8XPkjllCDpIIv34dQ1xPthv+v1giKAfbPjXHYaMXnxZ3Oz78WUY
 qPS1XJmCiIIxVC1OgcUFMri/rpYui7sLDDyWGcKtiXgxl6F2H5kxGKUIAlBZeOzfN0Si
 KnmTOVlcG5AqSt1OGJqXndzxu6VYjUGdgkBGIHCq7ushISZU5sbcFzwhW1xqC2Pp4dq1
 If1Q==
X-Gm-Message-State: ACgBeo0nkTzdtgchbMaB0uywZRtR9BwBjVFh4NV4KC52jfvhRD+46pYN
 OlsovubtFc0ngFusG5Y4lTnqfRVOd9/0Tg==
X-Google-Smtp-Source: AA6agR61jm+gnE6uIcAEOx0CBFCZSB5bCcM8p2TRehe7+MhulyzjkjLhRTPGxWfZjL0WReR9R9XuTQ==
X-Received: by 2002:a17:90b:1e08:b0:1f5:3874:492e with SMTP id
 pg8-20020a17090b1e0800b001f53874492emr21608510pjb.82.1660448883316; 
 Sat, 13 Aug 2022 20:48:03 -0700 (PDT)
Received: from localhost ([2409:8a70:2bf:80b0:8ec6:81ff:fe70:339d])
 by smtp.gmail.com with ESMTPSA id
 fs1-20020a17090af28100b001f246f2a423sm2410983pjb.17.2022.08.13.20.48.01
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 13 Aug 2022 20:48:02 -0700 (PDT)
From: Ihor Radchenko <yantar92@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 28.1.90; Can error backtrace be preserved upon intercepting with
 `condition-case'?
Date: Sun, 14 Aug 2022 11:49:04 +0800
Message-ID: <87edxj1o3z.fsf@localhost>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=2607:f8b0:4864:20::62b;
 envelope-from=yantar92@HIDDEN; helo=mail-pl1-x62b.google.com
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.1 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.1 (--)

Consider the following functions:

(defun my/err ()
  (let ((x 0))
    (/ 2 x)))

(defun my/interc ()
  (condition-case err
      (my/err)
    (arith-error
     (backtrace-revert)
     (error "`my/err' signalled an error. Check out Troubleshooting section of the manual. (%S)" err))))

`my/interc' function calls `my/err', but wants to provide a more useful
error message. This can obviously be done using `condition-case'.

However, when one tries to run M-: (my/interc), the following backtrace
will appear:

Debugger entered--Lisp error: (error "My custom error: (arith-error)")
  (error "My custom error: %S" (arith-error))
  (condition-case err (my/err) (arith-error (error "My custom error: %S" err)))
  (my/interc)
  (eval-expression (my/interc) nil nil 127)
  (funcall-interactively eval-expression (my/interc) nil nil 127)
  (command-execute eval-expression)

This backtrace is limiting the information up to the `condition-case'
form itself. The deeper levels are not available.

Compare it with the result of M-: (my/err)

Debugger entered--Lisp error: (arith-error)
  (/ 2 0)
  (let ((x 0)) (/ 2 x))
  (my/err)
  (eval-expression (my/err) nil nil 127)
  (funcall-interactively eval-expression (my/err) nil nil 127)
  (command-execute eval-expression)

This backtrace is much more detailed and gives the exact place where the
error happens.

Unfortunately, the second case does not allow to make the error message
more helpful.

Is it possible to display the original backtrace in the intercepted
condition-case?

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92




Acknowledgement sent to Ihor Radchenko <yantar92@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#57195; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 15 Aug 2022 07:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.