* Any downside to condition-case-unless-debug?
@ 2021-05-27 16:38 Eric Abrahamsen
2021-05-27 17:02 ` Glenn Morris
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Eric Abrahamsen @ 2021-05-27 16:38 UTC (permalink / raw)
To: emacs-devel
Hi,
I feel like a lot of my debugging recently has involved various ways of
working around `condition-case' and its swallowing of useful error
information. Is there any reason not to prefer
`condition-case-unless-debug' in new code?
Thanks,
Eric
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Any downside to condition-case-unless-debug?
2021-05-27 16:38 Any downside to condition-case-unless-debug? Eric Abrahamsen
@ 2021-05-27 17:02 ` Glenn Morris
2021-05-27 17:06 ` Eric Abrahamsen
2021-05-27 23:22 ` Stefan Monnier
2021-05-28 4:44 ` Richard Stallman
2 siblings, 1 reply; 7+ messages in thread
From: Glenn Morris @ 2021-05-27 17:02 UTC (permalink / raw)
To: Eric Abrahamsen; +Cc: emacs-devel
Eric Abrahamsen wrote:
> Is there any reason not to prefer `condition-case-unless-debug' in new
> code?
It breaks ert. https://debbugs.gnu.org/11218
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Any downside to condition-case-unless-debug?
2021-05-27 17:02 ` Glenn Morris
@ 2021-05-27 17:06 ` Eric Abrahamsen
0 siblings, 0 replies; 7+ messages in thread
From: Eric Abrahamsen @ 2021-05-27 17:06 UTC (permalink / raw)
To: Glenn Morris; +Cc: emacs-devel
Glenn Morris <rgm@gnu.org> writes:
> Eric Abrahamsen wrote:
>
>> Is there any reason not to prefer `condition-case-unless-debug' in new
>> code?
>
> It breaks ert. https://debbugs.gnu.org/11218
Oh, good to know, thanks. I guess I'll watch that bug report.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Any downside to condition-case-unless-debug?
2021-05-27 16:38 Any downside to condition-case-unless-debug? Eric Abrahamsen
2021-05-27 17:02 ` Glenn Morris
@ 2021-05-27 23:22 ` Stefan Monnier
2021-05-28 2:02 ` Eric Abrahamsen
2021-05-28 4:44 ` Richard Stallman
2 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2021-05-27 23:22 UTC (permalink / raw)
To: Eric Abrahamsen; +Cc: emacs-devel
> I feel like a lot of my debugging recently has involved various ways of
> working around `condition-case' and its swallowing of useful error
> information. Is there any reason not to prefer
> `condition-case-unless-debug' in new code?
IME, `condition-case-unless-debug' is used/useful mostly for
`condition-case` that catch "any error", most of which might be better
served by something like `with-demoted-errors`.
For those `condition-case` which catch one particular kind of error to
handle a particular expected situation (e.g. when catching `scan-error`
around a call to `forward-sexp`), `condition-case-unless-debug` rarely
makes sense.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Any downside to condition-case-unless-debug?
2021-05-27 23:22 ` Stefan Monnier
@ 2021-05-28 2:02 ` Eric Abrahamsen
0 siblings, 0 replies; 7+ messages in thread
From: Eric Abrahamsen @ 2021-05-28 2:02 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> I feel like a lot of my debugging recently has involved various ways of
>> working around `condition-case' and its swallowing of useful error
>> information. Is there any reason not to prefer
>> `condition-case-unless-debug' in new code?
>
> IME, `condition-case-unless-debug' is used/useful mostly for
> `condition-case` that catch "any error", most of which might be better
> served by something like `with-demoted-errors`.
>
> For those `condition-case` which catch one particular kind of error to
> handle a particular expected situation (e.g. when catching `scan-error`
> around a call to `forward-sexp`), `condition-case-unless-debug` rarely
> makes sense.
Yes, exactly! The cases I'm looking at are all cases that catch "any
error", often for no good reason (IMO). I'll try to tend towards patches
that remove `condition-case' altogether, rather than
`condition-case-unless-debug'.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Any downside to condition-case-unless-debug?
2021-05-27 16:38 Any downside to condition-case-unless-debug? Eric Abrahamsen
2021-05-27 17:02 ` Glenn Morris
2021-05-27 23:22 ` Stefan Monnier
@ 2021-05-28 4:44 ` Richard Stallman
2021-05-28 4:48 ` Eric Abrahamsen
2 siblings, 1 reply; 7+ messages in thread
From: Richard Stallman @ 2021-05-28 4:44 UTC (permalink / raw)
To: Eric Abrahamsen; +Cc: emacs-devel
[[[ To any NSA and FBI agents reading my email: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
> I feel like a lot of my debugging recently has involved various ways of
> working around `condition-case' and its swallowing of useful error
> information. Is there any reason not to prefer
> `condition-case-unless-debug' in new code?
If we wanted to have that behavior by default, then rather than change
lots of code gradually, how about making a new global flag
`debug-on-caught-error' which, when t, would make errors invoke
the debugger when they are about to be caught?
If `debug-on-caught-error' is `debug-on-error', then the value of
`debug-on-error' would control the behavior of errors about to be
caught.
--
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Any downside to condition-case-unless-debug?
2021-05-28 4:44 ` Richard Stallman
@ 2021-05-28 4:48 ` Eric Abrahamsen
0 siblings, 0 replies; 7+ messages in thread
From: Eric Abrahamsen @ 2021-05-28 4:48 UTC (permalink / raw)
To: emacs-devel
Richard Stallman <rms@gnu.org> writes:
> [[[ To any NSA and FBI agents reading my email: please consider ]]]
> [[[ whether defending the US Constitution against all enemies, ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
> > I feel like a lot of my debugging recently has involved various ways of
> > working around `condition-case' and its swallowing of useful error
> > information. Is there any reason not to prefer
> > `condition-case-unless-debug' in new code?
>
> If we wanted to have that behavior by default, then rather than change
> lots of code gradually, how about making a new global flag
> `debug-on-caught-error' which, when t, would make errors invoke
> the debugger when they are about to be caught?
>
> If `debug-on-caught-error' is `debug-on-error', then the value of
> `debug-on-error' would control the behavior of errors about to be
> caught.
Would this help work around the ERT interference that Glenn referenced?
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-05-28 4:48 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-27 16:38 Any downside to condition-case-unless-debug? Eric Abrahamsen
2021-05-27 17:02 ` Glenn Morris
2021-05-27 17:06 ` Eric Abrahamsen
2021-05-27 23:22 ` Stefan Monnier
2021-05-28 2:02 ` Eric Abrahamsen
2021-05-28 4:44 ` Richard Stallman
2021-05-28 4:48 ` Eric Abrahamsen
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).