1.0.43.41: TYPE-ERROR printing tweak for *PRINT-ESCAPE* = T
authorNikodemus Siivola <nikodemus@random-state.net>
Mon, 11 Oct 2010 14:29:13 +0000 (14:29 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Mon, 11 Oct 2010 14:29:13 +0000 (14:29 +0000)
 Print as #<TYPE-ERROR exptected-type: SOME-TYPE datum: SOME-DATUM> when
 possible.

 Virtually every time I see a TYPE-ERROR printed with *PRINT-ESCAPE* =
 T I need to go look for the place where it is printed in order to see
 what the actual problem is -- and I don't think I'm the only one.

 This is hopefully one annoyance less.

src/code/condition.lisp
version.lisp-expr

index 35603bc..541ab58 100644 (file)
              (type-error-datum condition)
              (type-error-expected-type condition)))))
 
+(def!method print-object ((condition type-error) stream)
+  (if *print-escape*
+      (flet ((maybe-string (thing)
+               (ignore-errors
+                 (write-to-string thing :lines 1 :readably nil :array nil :pretty t))))
+        (let ((type (maybe-string (type-error-expected-type condition)))
+              (datum (maybe-string (type-error-datum condition))))
+          (if (and type datum)
+              (print-unreadable-object (condition stream :type t)
+                (format stream "~@<expected-type: ~A ~_datum: ~A~:@>" type datum))
+              (call-next-method))))
+      (call-next-method)))
+
 ;;; not specified by ANSI, but too useful not to have around.
 (define-condition simple-style-warning (simple-condition style-warning) ())
 (define-condition simple-type-error (simple-condition type-error) ())
index bb57b58..eb5fa2a 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.43.40"
+"1.0.43.41"