From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleksandr Gavenko Newsgroups: gmane.emacs.help Subject: Re: Reporting error to user... Date: Mon, 04 Mar 2013 21:23:12 +0200 Organization: Oleksandr Gavenko , http://gavenkoa.users.sf.net Message-ID: <871ubvufz3.fsf@gavenkoa.example.com> References: <87fw0cmht6.fsf@gavenkoa.example.com> <87k3po1de2.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1362425022 1819 80.91.229.3 (4 Mar 2013 19:23:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 4 Mar 2013 19:23:42 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Mar 04 20:24:06 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UCazV-0006ai-KC for geh-help-gnu-emacs@m.gmane.org; Mon, 04 Mar 2013 20:24:05 +0100 Original-Received: from localhost ([::1]:54676 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCazA-00042d-5E for geh-help-gnu-emacs@m.gmane.org; Mon, 04 Mar 2013 14:23:44 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:48572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCayy-00042L-16 for help-gnu-emacs@gnu.org; Mon, 04 Mar 2013 14:23:33 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UCayw-0002U9-Dp for help-gnu-emacs@gnu.org; Mon, 04 Mar 2013 14:23:31 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:39784) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCayv-0002Tn-JV for help-gnu-emacs@gnu.org; Mon, 04 Mar 2013 14:23:30 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UCazD-0006Lx-Ic for help-gnu-emacs@gnu.org; Mon, 04 Mar 2013 20:23:47 +0100 Original-Received: from 37.229.4.200 ([37.229.4.200]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 04 Mar 2013 20:23:47 +0100 Original-Received: from gavenkoa by 37.229.4.200 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 04 Mar 2013 20:23:47 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 62 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 37.229.4.200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) Cancel-Lock: sha1:3UazKtdSw/POqOyOUUNF2noRO+8= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:89344 Archived-At: On 2013-03-03, Jambunathan K wrote: > Oleksandr Gavenko 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 * 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!