all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Reporting error to user...
@ 2013-03-03 18:58 Oleksandr Gavenko
  2013-03-03 19:39 ` Jambunathan K
  0 siblings, 1 reply; 5+ messages in thread
From: Oleksandr Gavenko @ 2013-03-03 18:58 UTC (permalink / raw)
  To: help-gnu-emacs

I wrote blogging program in Elisp and have to report errors to users (when
required file not found or network authorisation failed).

How to report error to users?

I think that showing *Backtrace* buffer from '(error ...)' is not good way to
do this (I have filling that such behavior indicates bug or "not yet
implemented" condition in program).

(message "...") is better but sometimes another modes hide minibufer text
(like semantic when showing symbol type).

Would like to hear suggestions...

-- 
Best regards!




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

* Re: Reporting error to user...
  2013-03-03 18:58 Reporting error to user Oleksandr Gavenko
@ 2013-03-03 19:39 ` Jambunathan K
  2013-03-04 19:23   ` Oleksandr Gavenko
  0 siblings, 1 reply; 5+ messages in thread
From: Jambunathan K @ 2013-03-03 19:39 UTC (permalink / raw)
  To: Oleksandr Gavenko; +Cc: help-gnu-emacs



Last couple of sentences down below may interest you.

,---- From (info "(elisp) Signaling Errors")
|
|  -- Function: user-error format-string &rest args
|      This function behaves exactly like `error', except that it uses
|      the error symbol `user-error' rather than `error'.  As the name
|      suggests, this is intended to report errors on the part of the
|      user, rather than errors in the code itself.  For example, if you
|      try to use the command `Info-history-back' (`l') to move back
|      beyond the start of your Info browsing history, Emacs signals a
|      `user-error'.  Such errors do not cause entry to the debugger,
|      even when `debug-on-error' is non-`nil'.  *Note Error
|      Debugging::.
|
`----

Oleksandr Gavenko <gavenkoa@gmail.com> writes:

> I wrote blogging program in Elisp and have to report errors to users (when
> required file not found or network authorisation failed).
>
> How to report error to users?
>
> I think that showing *Backtrace* buffer from '(error ...)' is not good way to
> do this (I have filling that such behavior indicates bug or "not yet
> implemented" condition in program).
>
> (message "...") is better but sometimes another modes hide minibufer text
> (like semantic when showing symbol type).
>
> Would like to hear suggestions...

-- 



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

* Re: Reporting error to user...
  2013-03-03 19:39 ` Jambunathan K
@ 2013-03-04 19:23   ` Oleksandr Gavenko
  2013-03-05  4:51     ` Dmitry Gutov
  0 siblings, 1 reply; 5+ messages in thread
From: Oleksandr Gavenko @ 2013-03-04 19:23 UTC (permalink / raw)
  To: help-gnu-emacs

On 2013-03-03, Jambunathan K wrote:

> Oleksandr Gavenko <gavenkoa@gmail.com> writes:
>
>> I wrote blogging program in Elisp and have to report errors to users (when
>> required file not found or network authorisation failed).
>>
>> How to report error to users?
>>
>> I think that showing *Backtrace* buffer from '(error ...)' is not good way to
>> do this (I have filling that such behavior indicates bug or "not yet
>> implemented" condition in program).
>>
>> (message "...") is better but sometimes another modes hide minibufer text
>> (like semantic when showing symbol type).
>>
>> Would like to hear suggestions...
>
> Last couple of sentences down below may interest you.
>
> ,---- From (info "(elisp) Signaling Errors")
> |
> |  -- Function: user-error format-string &rest args
> |      This function behaves exactly like `error', except that it uses
> |      the error symbol `user-error' rather than `error'.  As the name
> |      suggests, this is intended to report errors on the part of the
> |      user, rather than errors in the code itself.  For example, if you
> |      try to use the command `Info-history-back' (`l') to move back
> |      beyond the start of your Info browsing history, Emacs signals a
> |      `user-error'.  Such errors do not cause entry to the debugger,
> |      even when `debug-on-error' is non-`nil'.  *Note Error
> |      Debugging::.
> |
> `----

Hm... (describe-function 'user-error) return (void-function user-error).

I use Emacs 24.2.1.


From bzr repo:

  2012-05-04  Stefan Monnier  <monnier@...>

      * data.c (PUT_ERROR): New macro.
      (syms_of_data): Use it.  Add new error type `user-error'.

Build from trunk beep and show error message in minibuffer on 'user-error'.


How to backport 'user-error' into early Emacs versions? Do I need to write
a wrapper:

  (defun my-user-error (format &rest args)
    (if (fboundp 'user-error))
         (apply 'user-error format args)
       (apply 'error format args))

in my mode and use 'my-user-error' instead if 'user-error'?

-- 
Best regards!




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

* Re: Reporting error to user...
  2013-03-04 19:23   ` Oleksandr Gavenko
@ 2013-03-05  4:51     ` Dmitry Gutov
  2013-03-05 21:32       ` Oleksandr Gavenko
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Gutov @ 2013-03-05  4:51 UTC (permalink / raw)
  To: Oleksandr Gavenko; +Cc: help-gnu-emacs

Oleksandr Gavenko <gavenkoa@gmail.com> writes:
> How to backport 'user-error' into early Emacs versions? Do I need to write
> a wrapper:
>
>   (defun my-user-error (format &rest args)
>     (if (fboundp 'user-error))
>          (apply 'user-error format args)
>        (apply 'error format args))
>
> in my mode and use 'my-user-error' instead if 'user-error'?

You can just copy the implementation, it's trivial.



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

* Re: Reporting error to user...
  2013-03-05  4:51     ` Dmitry Gutov
@ 2013-03-05 21:32       ` Oleksandr Gavenko
  0 siblings, 0 replies; 5+ messages in thread
From: Oleksandr Gavenko @ 2013-03-05 21:32 UTC (permalink / raw)
  To: help-gnu-emacs

On 2013-03-05, Dmitry Gutov wrote:

> Oleksandr Gavenko <gavenkoa@gmail.com> writes:
>> How to backport 'user-error' into early Emacs versions? Do I need to write
>> a wrapper:
>>
>>   (defun my-user-error (format &rest args)
>>     (if (fboundp 'user-error))
>>          (apply 'user-error format args)
>>        (apply 'error format args))
>>
>> in my mode and use 'my-user-error' instead if 'user-error'?
>
> You can just copy the implementation, it's trivial.
>
While implementation is trivial (from 'emacs-bzr/trunk/lisp/subr.el'):

  (defun user-error (format &rest args)
    (while t
      (signal 'user-error (list (apply #'format format args)))))

I eval: (symbol-plist 'user-error) and get:

  (error-conditions (user-error error) error-message "")

But I can't find a place which put 'error-conditions' to 'user-error' symbol.

Really this must be done, from 'signal' docs:

     The argument ERROR-SYMBOL must be an "error symbol"--a symbol
     bearing a property `error-conditions' whose value is a list of
     condition names.

-- 
Best regards!




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

end of thread, other threads:[~2013-03-05 21:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-03 18:58 Reporting error to user Oleksandr Gavenko
2013-03-03 19:39 ` Jambunathan K
2013-03-04 19:23   ` Oleksandr Gavenko
2013-03-05  4:51     ` Dmitry Gutov
2013-03-05 21:32       ` Oleksandr Gavenko

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.