Add repl-print-exception.

This commit is contained in:
Alex Shinn 2024-10-29 21:45:00 +09:00
parent f4e3c0fd0b
commit 416da21528
2 changed files with 9 additions and 3 deletions

View file

@ -1,5 +1,5 @@
;; repl.scm - friendlier repl with line editing and signal handling
;; Copyright (c) 2012-2013 Alex Shinn. All rights reserved.
;; Copyright (c) 2012-2024 Alex Shinn. All rights reserved.
;; BSD-style license: http://synthcode.com/license.txt
;;> A user-friendly REPL with line editing and signal handling. The
@ -407,6 +407,11 @@
(define-method (repl-print obj (out output-port?))
(write/ss obj out))
(define-generic repl-print-exception)
(define-method (repl-print-exception obj (out output-port?))
(print-exception obj out))
(define (repl/eval rp expr-list)
(let ((thread (current-thread))
(out (repl-out rp)))
@ -416,7 +421,7 @@
(lambda ()
(protect (exn
(else
(print-exception exn out)
(repl-print-exception exn out)
(repl-advise-exception exn (current-error-port))))
(for-each
(lambda (expr)

View file

@ -1,6 +1,7 @@
(define-library (chibi repl)
(export repl repl-print $0 $1 $2 $3 $4 $5 $6 $7 $8 $9)
(export repl repl-print repl-print-exception
$0 $1 $2 $3 $4 $5 $6 $7 $8 $9)
(import (chibi) (only (meta) load-module module-name->file)
(chibi ast) (chibi modules) (chibi doc) (chibi generic)
(chibi string) (chibi io) (chibi optional)