[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Non-descriptive error-message
From: |
Pavel Janík |
Subject: |
Re: Non-descriptive error-message |
Date: |
Thu, 08 Nov 2001 21:26:53 +0100 |
User-agent: |
Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.1.50 (i386-suse-linux-gnu) |
From: Richard Stallman <address@hidden>
Date: Wed, 7 Nov 2001 21:53:09 -0700 (MST)
> (setq expr (read (current-buffer)))
>
> How do I properly catch an error here and report it to user in the
same way
> read signals "End of file during parsing" error?
>
> You can use `condition-case' around the call to `read':
>
> (condition-case error-data
> (read)
> (error ...))
Of course, but then I can not signal an error *in the same way* to the
user. error will pop-up the debugger, but after simple
emacs -q -f eval-print-last-sexp
you see only "End of file during parsing" message in the
echo-area. No debugger. I think we should use the same semantics here so
the user is not confused (he could press C-j accidentally).
> See the Emacs Lisp Manual for details. Note that there is currently
> no way to distinguish end of file from other read errors except to
> look at error-data. Maybe it is better to check explicitly for the
> just-whitespace case before calling read.
Something like this?
(narrow-to-region (point-min) opoint)
+ (if (string-match (buffer-string) "[^ \t\n]")
+ (error "No expression to evaluate"))
(setq expr (read (current-buffer)))
But this also does not signal an error the same way as I wrote
above. Do you see the solution?
--
Pavel Janík
Use the fundamental control flow constructs.
-- The Elements of Programming Style (Kernighan & Plaugher)