From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.bugs Subject: bug#57195: 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 Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40937"; mail-complaints-to="usenet@ciao.gmane.io" To: 57195@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Aug 14 05:49:28 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oN4cy-000AQs-BR for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 14 Aug 2022 05:49:28 +0200 Original-Received: from localhost ([::1]:35612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oN4cw-0004u4-ME for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 13 Aug 2022 23:49:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33730) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oN4cY-0004ti-OS for bug-gnu-emacs@gnu.org; Sat, 13 Aug 2022 23:49:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45786) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oN4cY-0006u5-Fq for bug-gnu-emacs@gnu.org; Sat, 13 Aug 2022 23:49:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oN4cY-0007fV-4a for bug-gnu-emacs@gnu.org; Sat, 13 Aug 2022 23:49:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 14 Aug 2022 03:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 57195 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.166044890029419 (code B ref -1); Sun, 14 Aug 2022 03:49:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 14 Aug 2022 03:48:20 +0000 Original-Received: from localhost ([127.0.0.1]:35535 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oN4bs-0007eR-6T for submit@debbugs.gnu.org; Sat, 13 Aug 2022 23:48:20 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:51152) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oN4bn-0007e8-4C for submit@debbugs.gnu.org; Sat, 13 Aug 2022 23:48:18 -0400 Original-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 ) id 1oN4bm-0004rg-7N for bug-gnu-emacs@gnu.org; Sat, 13 Aug 2022 23:48:14 -0400 Original-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 ) id 1oN4bk-0006rb-2k for bug-gnu-emacs@gnu.org; Sat, 13 Aug 2022 23:48:13 -0400 Original-Received: by mail-pl1-x62b.google.com with SMTP id 13so3825683plo.12 for ; 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) Original-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 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Aug 2022 20:48:02 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=yantar92@gmail.com; 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:239605 Archived-At: 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