Skip to content

Commit

Permalink
Add repl-print-exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashinn committed Oct 29, 2024
1 parent f4e3c0f commit 416da21
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions lib/chibi/repl.scm
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)))
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion lib/chibi/repl.sld
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 416da21

Please sign in to comment.