all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* use of `user-error'
@ 2013-03-07 16:36 Drew Adams
  2013-04-29 17:56 ` Michael Heerdegen
  0 siblings, 1 reply; 9+ messages in thread
From: Drew Adams @ 2013-03-07 16:36 UTC (permalink / raw)
  To: emacs-devel

1. I see many places in the trunk source code where `error' is used instead of
`user-error' and where I would naively expect the latter to be used.

Is this because most occurrences of `error' have simply not yet been updated to
`user-error', or am I misunderstanding what `user-error' is for?

It seems to me that _most_ existing occurrences of `error' are in fact places
where `user-error' should be used, according to the doc.  They represent pilot
error and not source-code bug situations that should never arise.  Am I
mistaken?


2. When `user-error' is used, a user will not get a backtrace, even with non-nil
`debug-on-error'.

For a developer to request that a user obtain a backtrace in such a case, it
seems that s?he must now ask the user to also customize `debug-ignored-errors'
to remove `user-error' from the value, in addition to turning on
`debug-on-error'.

That is a bit of bother to explain and do.  Is there a simpler approach?  It
used to be enough to tell a user to turn on `debug-on-error'.  Now they must
fiddle a bit more, it seems.  Can this be remedied?


3. 3rd-party developers often look to the Emacs source code as a guideline for
new things like this.

If I see that `choose-completion' uses `(error "Destination buffer is dead")',
that should give me an idea of what is really meant by a user error and whether
that particular error is expected in the normal course of things (pilot error)
or might represent a source-code bug (shouldn't happen normally).

In this case, whether a dead buffer here represents an Emacs problem or a pilot
problem.  In the case of a dead buffer it's not so easy to tell, but in the case
of `(error "No completion here")' it seems a good guess that it is a pilot error
(i.e., it should be `user-error').

If Emacs Dev will in fact take a long time to switch to using `user-error' where
appropriate - at least for most of the core code, that will cause some
confusion, as others will look to that code for guidance and get the wrong
message here or there.

We've already seen a fair amount of confusion over the interpretation of
`user-error' on both emacs-devel and the bug list, based only on the doc.
Inappropriate core source code will only make this worse.

OT1H, perhaps it would be better NOT to introduce (advertise) `user-error' until
more (most?) of the existing source code has been converted to use it.  OTOH, it
should be documented fully when it is introduced.

Maybe the best solution is for Emacs 24.3 NOT to be released until more of the
code has been converted to properly reflect the introduction of `user-error'?

(I can guess that this is what RMS might have preferred to do: Get it right in
the first place - maybe not in all of the source code, but in most of it.)




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: use of `user-error'
  2013-03-07 16:36 use of `user-error' Drew Adams
@ 2013-04-29 17:56 ` Michael Heerdegen
  2013-04-30 12:00   ` Xue Fuqiao
  2013-05-05  4:45   ` Stefan Monnier
  0 siblings, 2 replies; 9+ messages in thread
From: Michael Heerdegen @ 2013-04-29 17:56 UTC (permalink / raw)
  To: Drew Adams; +Cc: emacs-devel

Hi,

I really would like to discuss these questions raised by Drew (see
at the bottom, shortened!).

I would love to have `debug-on-error' bound to t all the time, to get an
immediate backtrace of errors that happen very rarely and are hard to
reproduce.  But getting a popped up debugger every time I hit a wrong
key or did something obviously wrong by accident is a pain in the ass.

So, can we try to substitute the appropriate occurrences of `error' by
`user-error', or are there any things that prevent us from doing that?


Thanks,

Michael.

> 1. I see many places in the trunk source code where `error' is used
> instead of `user-error' and where I would naively expect the latter to
> be used.
>
> Is this because most occurrences of `error' have simply not yet been
> updated to `user-error', or am I misunderstanding what `user-error' is
> for? [...]

> 2. When `user-error' is used, a user will not get a backtrace, even
> with non-nil `debug-on-error'.
>
> For a developer to request that a user obtain a backtrace in such a
> case, it seems that s?he must now ask the user to also customize
> debug-ignored-errors' to remove `user-error' from the value, in
> addition to turning on `debug-on-error'.
>
> That is a bit of bother to explain and do.  Is there a simpler
> approach? [...]

> 3. 3rd-party developers often look to the Emacs source code as a
> guideline for new things like this. [...]



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: use of `user-error'
  2013-04-29 17:56 ` Michael Heerdegen
@ 2013-04-30 12:00   ` Xue Fuqiao
  2013-05-05  4:45   ` Stefan Monnier
  1 sibling, 0 replies; 9+ messages in thread
From: Xue Fuqiao @ 2013-04-30 12:00 UTC (permalink / raw)
  To: Drew Adams, emacs-devel

On Tue, Apr 30, 2013 at 1:56 AM, Michael Heerdegen
<michael_heerdegen@web.de> wrote:
> Hi,

Hi,

> So, can we try to substitute the appropriate occurrences of `error' by
> `user-error', or are there any things that prevent us from doing that?

IMO we can substitute most occurrences of `error' by `user-error'.  My
reasons are similiar to Drew's.

--
Best regards, Xue Fuqiao.
http://www.gnu.org/software/emacs/



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: use of `user-error'
  2013-04-29 17:56 ` Michael Heerdegen
  2013-04-30 12:00   ` Xue Fuqiao
@ 2013-05-05  4:45   ` Stefan Monnier
  2013-05-05 13:29     ` Drew Adams
  1 sibling, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2013-05-05  4:45 UTC (permalink / raw)
  To: Drew Adams; +Cc: emacs-devel

> I would love to have `debug-on-error' bound to t all the time, to get an
> immediate backtrace of errors that happen very rarely and are hard to
> reproduce.  But getting a popped up debugger every time I hit a wrong
> key or did something obviously wrong by accident is a pain in the ass.

I do have debug-on-error set to t in my .emacs.  If you regularly get
backtraces in this situation, then we should probably replace some
of those errors with user-errors.

> So, can we try to substitute the appropriate occurrences of `error' by
> `user-error', or are there any things that prevent us from doing that?

Nothing, except for the fact that we should do it on
a case-by-case basis.

`user-error' was mostly introduced to trim down debug-ignored-errors and
to make it easier for the programmer to signal a non-backtrace-popping
error (which used to require adding an entry to debug-ignored-errors).
And yes, there are many `error's which would benefit from being turned
into `user-errors'.  But search&replace is not a good way to do it.


        Stefan



^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: use of `user-error'
  2013-05-05  4:45   ` Stefan Monnier
@ 2013-05-05 13:29     ` Drew Adams
  2013-05-05 13:40       ` Dmitry Gutov
  0 siblings, 1 reply; 9+ messages in thread
From: Drew Adams @ 2013-05-05 13:29 UTC (permalink / raw)
  To: 'Stefan Monnier'; +Cc: emacs-devel

> > I would love to have `debug-on-error' bound to t...

> And yes, there are many `error's which would benefit
> from being turned into `user-errors'.  But search&replace
> is not a good way to do it.

Whatever way you think is a good way, go for it.

[FYI - Somehow, your reply was to me as `To:', but the message you replied to
(and quoted) was from Michael, not me.]




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: use of `user-error'
  2013-05-05 13:29     ` Drew Adams
@ 2013-05-05 13:40       ` Dmitry Gutov
  2013-05-05 18:16         ` Josh
  2013-05-08 13:24         ` Xue Fuqiao
  0 siblings, 2 replies; 9+ messages in thread
From: Dmitry Gutov @ 2013-05-05 13:40 UTC (permalink / raw)
  To: Drew Adams; +Cc: 'Stefan Monnier', emacs-devel

"Drew Adams" <drew.adams@oracle.com> writes:

>> > I would love to have `debug-on-error' bound to t...
>
>> And yes, there are many `error's which would benefit
>> from being turned into `user-errors'.  But search&replace
>> is not a good way to do it.
>
> Whatever way you think is a good way, go for it.

I believe Stefan's meaning was that the users should go ahead and
collect specific examples (functions and lines) where `errors' should be
replaced with `user-errors'.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: use of `user-error'
  2013-05-05 13:40       ` Dmitry Gutov
@ 2013-05-05 18:16         ` Josh
  2013-05-06  1:44           ` Stefan Monnier
  2013-05-08 13:24         ` Xue Fuqiao
  1 sibling, 1 reply; 9+ messages in thread
From: Josh @ 2013-05-05 18:16 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: Stefan Monnier, Drew Adams, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 297 bytes --]

On Sun, May 5, 2013 at 6:40 AM, Dmitry Gutov <dgutov@yandex.ru> wrote:

> I believe Stefan's meaning was that the users should go ahead and
>  collect specific examples (functions and lines) where `errors' should be
> replaced with `user-errors'.
>

windmove-do-window-select is one such example.

[-- Attachment #2: Type: text/html, Size: 755 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: use of `user-error'
  2013-05-05 18:16         ` Josh
@ 2013-05-06  1:44           ` Stefan Monnier
  0 siblings, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2013-05-06  1:44 UTC (permalink / raw)
  To: Josh; +Cc: emacs-devel, Drew Adams, Dmitry Gutov

>> I believe Stefan's meaning was that the users should go ahead and
>> collect specific examples (functions and lines) where `errors' should be
>> replaced with `user-errors'.
> windmove-do-window-select is one such example.

Sounds reasonable (to the extent that windmove functions aren't called
from Elisp).


        Stefan



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: use of `user-error'
  2013-05-05 13:40       ` Dmitry Gutov
  2013-05-05 18:16         ` Josh
@ 2013-05-08 13:24         ` Xue Fuqiao
  1 sibling, 0 replies; 9+ messages in thread
From: Xue Fuqiao @ 2013-05-08 13:24 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: Stefan Monnier, Drew Adams, emacs-devel

On Sun, May 5, 2013 at 9:40 PM, Dmitry Gutov <dgutov@yandex.ru> wrote:
> I believe Stefan's meaning was that the users should go ahead and
> collect specific examples (functions and lines) where `errors' should be
> replaced with `user-errors'.

IIUC `eshell-previous-matching-input' is one such example.

--
Best regards, Xue Fuqiao.
http://www.gnu.org/software/emacs/



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-05-08 13:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-07 16:36 use of `user-error' Drew Adams
2013-04-29 17:56 ` Michael Heerdegen
2013-04-30 12:00   ` Xue Fuqiao
2013-05-05  4:45   ` Stefan Monnier
2013-05-05 13:29     ` Drew Adams
2013-05-05 13:40       ` Dmitry Gutov
2013-05-05 18:16         ` Josh
2013-05-06  1:44           ` Stefan Monnier
2013-05-08 13:24         ` Xue Fuqiao

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.