Subject: Re: how to print message coming from (error "...")
From: rpw3@rpw3.org (Rob Warnock)
Date: Fri, 29 Jun 2007 05:36:24 -0500
Newsgroups: comp.lang.lisp
Message-ID: <jKmdnVjwF7k1fRnbnZ2dnUVZ_gCdnZ2d@speakeasy.net>
Carl Taylor <carltaylor@att.net> wrote:
+---------------
| CL-USER 1 > 
| (handler-case (/ 123 0)
|      (error (condition)
|          (format *error-output* "~2%~6T~S~#%" condition)
|           nil))
| 
| 
|       #<DIVISION-BY-ZERO 200BB04B>
| NIL
+---------------

One usually wants "~A" here instead of "~S", since "~S" usually
just prints the unreadable object, while "~A" ("aesthetic format")
often prints much more useful information, e.g.:

    > (handler-case (/ 123 0)
        (error (condition)
          (format *error-output* "~&~A~%" condition)))

    Arithmetic error DIVISION-BY-ZERO signalled.
    Operation was KERNEL::DIVISION, operands (123 0).

    NIL
    > 

Of course, how much more depends on the implementation, but...


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607