summaryrefslogtreecommitdiff
path: root/scheme
diff options
context:
space:
mode:
authorChaos Eternal <chaos@shlug.org>2017-08-18 16:27:30 +0800
committerChaos Eternal <chaos@shlug.org>2017-08-18 17:00:32 +0800
commitac2c6b7e3382d21113193059d9b19ba60b802a46 (patch)
treedfea57e18be7a2b794a527efc502cb0a7b61af72 /scheme
parentdd08e3d83d070eb8d041d66217b4591a55729024 (diff)
downloadgeiser-guile-ac2c6b7e3382d21113193059d9b19ba60b802a46.tar.gz
geiser-guile-ac2c6b7e3382d21113193059d9b19ba60b802a46.tar.bz2
Handle exceptions of ChezScheme and multi-value as well
- Capture exceptions of ChezScheme - handles multi-value return
Diffstat (limited to 'scheme')
-rw-r--r--scheme/chez/geiser/geiser.ss31
1 files changed, 27 insertions, 4 deletions
diff --git a/scheme/chez/geiser/geiser.ss b/scheme/chez/geiser/geiser.ss
index 2fa648c..6568120 100644
--- a/scheme/chez/geiser/geiser.ss
+++ b/scheme/chez/geiser/geiser.ss
@@ -30,11 +30,34 @@
(define (geiser:eval module form . rest)
rest
- (let ((result (if module
- (eval form (environment module))
- (eval form))))
+ (let* ((try-eval (lambda (x . y)
+ (call/cc
+ (lambda (k)
+ (with-exception-handler
+ (lambda (e)
+ (k e))
+ (lambda ()
+ (if (null? y) (eval x)
+ (eval x (car y)))
+ ))))))
+ (result-mid (call-with-values
+ (lambda () (if module
+ (try-eval form (environment module))
+ (try-eval form)))
+ (lambda (x . y)
+ (if (null? y)
+ x
+ (cons x y)))))
+ (result result-mid)
+ (error (if (condition? result-mid)
+ (cons 'error (list
+ (cons 'key
+ (with-output-to-string
+ (lambda () (display-condition result-mid))))))
+ '())))
(write `((result ,(write-to-string result))
- (output . "")))
+ (output . "")
+ ,error))
(newline)))
(define (geiser:module-completions prefix . rest)