summaryrefslogtreecommitdiff
path: root/scheme/geiser
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2009-02-08 11:56:30 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2009-02-08 11:56:30 +0100
commit0935e89110296b884d06141b5b4386122f18403e (patch)
tree61678f917a350a9f9fbffae57d14ea6f60f0e069 /scheme/geiser
parent377d6d19debce5572052727323931f1b8306226b (diff)
downloadgeiser-guile-0935e89110296b884d06141b5b4386122f18403e.tar.gz
geiser-guile-0935e89110296b884d06141b5b4386122f18403e.tar.bz2
Better error presentation.
Diffstat (limited to 'scheme/geiser')
-rw-r--r--scheme/geiser/eval.scm22
1 files changed, 18 insertions, 4 deletions
diff --git a/scheme/geiser/eval.scm b/scheme/geiser/eval.scm
index 3e800c9..81b2647 100644
--- a/scheme/geiser/eval.scm
+++ b/scheme/geiser/eval.scm
@@ -25,18 +25,32 @@
;;; Code:
(define-module (geiser eval)
- #:export (eval-in))
+ #:export (eval-in)
+ #:use-module (srfi srfi-1))
(define (eval-in form module-name)
"Evals FORM in the module designated by MODULE-NAME.
If MODULE-NAME is #f or resolution fails, the current module is used instead.
The result is a list of the form ((RESULT . <form-value>))
-if no evaluation error happens, or ((ERROR <error-key> <error-arg>...))
-in case of errors."
+if no evaluation error happens, or ((ERROR (KEY . <error-key>) <error-arg>...))
+in case of errors. Each error arg is a cons (NAME . VALUE), where NAME includes
+SUBR, MSG and REST."
(let ((module (or (and module-name (resolve-module module-name))
(current-module))))
(catch #t
(lambda () (list (cons 'result (eval form module))))
- (lambda (key . args) (list (cons 'error (cons key args)))))))
+ (lambda (key . args)
+ (list (cons 'error (apply parse-error (cons key args))))))))
+
+(define (parse-error key . args)
+ (let* ((len (length args))
+ (subr (and (> len 0) (first args)))
+ (msg (and (> len 1) (second args)))
+ (margs (and (> len 2) (third args)))
+ (rest (and (> len 3) (fourth args))))
+ (list (cons 'key key)
+ (cons 'subr (or subr '()))
+ (cons 'msg (if msg (apply format (cons #f (cons msg margs))) '()))
+ (cons 'rest (or rest '())))))
;;; eval.scm ends here