repl: use error-object? to decide whether an error or an exception was raised

This makes error messages a bit more informative.  Also, if error objects become
a distinct type, then the repl implementation will continue to be correct. The
(deleted) second cond clause seemed to be bit redundant - I am not sure what the
original intent was.
This commit is contained in:
Yorick Hardy 2025-02-16 17:58:05 +02:00
parent bb2b589b74
commit 371dd7a7d0

View file

@ -20,9 +20,9 @@
(define (repl)
(with-handler
(lambda (obj)
(display "Error: ")
(cond
((error-object? obj)
(display "Error: ")
(display (error-object-message obj))
(if (not (null? (error-object-irritants obj)))
(display ": "))
@ -31,18 +31,8 @@
(write o)
(display " "))
(error-object-irritants obj)))
((pair? obj)
(when (string? (car obj))
(display (car obj))
(if (not (null? (cdr obj)))
(display ": "))
(set! obj (cdr obj)))
(for-each
(lambda (o)
(write o)
(display " "))
obj))
(else
(display "Exception: ")
(display obj)))
(newline)
(repl))