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) (define (repl)
(with-handler (with-handler
(lambda (obj) (lambda (obj)
(display "Error: ")
(cond (cond
((error-object? obj) ((error-object? obj)
(display "Error: ")
(display (error-object-message obj)) (display (error-object-message obj))
(if (not (null? (error-object-irritants obj))) (if (not (null? (error-object-irritants obj)))
(display ": ")) (display ": "))
@ -31,18 +31,8 @@
(write o) (write o)
(display " ")) (display " "))
(error-object-irritants obj))) (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 (else
(display "Exception: ")
(display obj))) (display obj)))
(newline) (newline)
(repl)) (repl))