Gauche Devlog

< Easier installation |

2018/05/13

Plugged an annoying error behavior

I've been aware of an annoying behavior in Gauche. From time to time, I myself got bitten by it and thought "Gee, it's terrible! I should fix it." But there was always more urgent tasks to finish so it was let untouched.

It is that, when an error is caused by a huge object (e.g. long list or deep tree), Gauche tries to report the offending object entirely, producing huge error message:

*** ERROR: vector required, but got (*TOP* (html (head (title "RSSMix: Recent En
tries") (link (|@| (type "text/css") (rel "stylesheet") (href "wiliki-sample.css
")))) (body (h1 "RSSMix: Recent Entries") (div (|@| (align "right")) "[" (a (|@|
 (href "http://practical-scheme.net/wiliki/wiliki.cgi?WiLiKi:RSSMix")) "What's T
his?") "][" (a (|@| (href "?c=info")) "Sources") "]") (hr) (table (tr (td "2018/
05/13 16:27:40 UTC") (td (a (|@| (href "http://ja.reddit.com/r/lisp_ja/")) "Redd
it - LISP ja") ": " (a (|@| (href "https://ja.reddit.com/r/lisp_ja/comments/8j4y
ff/実行時のデータ型の表現手法_2012/")) "実行時のデータ型の表現手法 (2012)"))) (tr (td "20
18/05/13 15:11:00 UTC") (td (a (|@| (href "http://ja.reddit.com/r/lisp_ja/")) "R
eddit - LISP ja") ": " (a (|@| (href "https://ja.reddit.com/r/lisp_ja/comments/8
j4ez7/evolution_in_lisps_qiita/")) "Evolution In LISPs - Qiita"))) (tr (td "2018
...

It is especially bad when you're running gosh in *scheme* buffer of Emacs with font-lock mode. Emacs starts to parse this huge S-expression and does nothing else---even not accepting keystrokes.

Yesterday I hit it again and had to kill Emacs. That was the last straw.

It turns out it's so simple that I wonder why I didn't already do it long time ago.

--- a/src/libexc.scm
+++ b/src/libexc.scm
@@ -73,7 +73,7 @@
             (values '() (list exc)))
         (let1 name (condition-type-name exc)
           (if (condition-has-type? exc <message-condition>)
-            (format out "*** ~a: ~a\n" name (~ exc'message))
+            (format out "*** ~a: ~,,,,200:a\n" name (~ exc'message))
             (format out "*** ~a\n" name)))
         (for-each (cut report-mixin-condition <> out) mixins)))))

Now the error message is truncated if it's too long.

*** ERROR: vector required, but got ((*TOP* (html (head (title "RSSMix:
 Recent Entries") (link (|@| (type "text/css") (rel "stylesheet") (href
 "wiliki-sample.css")))) (body (h1 "RSSMix: Recent Entries") (div ...
Stack Trace:
_______________________________________
  0  (vector-ref zz 1)
        at "(standard input)":4

Tag: 0.9.6

Post a comment

Name: