diff --git a/module/mes/repl.mes b/module/mes/repl.mes index aa18a836..dc2daef2 100644 --- a/module/mes/repl.mes +++ b/module/mes/repl.mes @@ -159,23 +159,29 @@ along with Mes. If not, see . (force-output) (let ((sexp (read-env a))) (when (not (eq? sexp '())) - (when print-sexp? - (display "[sexp=") - (display sexp) - (display "]") - (newline)) - (cond ((and (pair? sexp) (eq? (car sexp) (string->symbol "unquote"))) - (let ((r (meta (cadr sexp) a))) - (if (pair? r) (loop (append r a)) - (loop a)))) - ((and (pair? sexp) (eq? (car sexp) 'mes-use-module)) - (loop (mes-load-module-env (cadr sexp) a))) - (else (let ((e (eval sexp a))) - (if (eq? e *unspecified*) (loop a) - (let ((id (string->symbol (string-append "$" (number->string count))))) - (set! count (+ count 1)) - (display id) - (display " = ") - (display e) - (newline) - (loop (acons id e a)))))))))))) + (catch #t + (lambda () + (when print-sexp? + (display "[sexp=") + (display sexp) + (display "]") + (newline)) + (cond ((and (pair? sexp) (eq? (car sexp) (string->symbol "unquote"))) + (let ((r (meta (cadr sexp) a))) + (if (pair? r) (loop (append r a)) + (loop a)))) + ((and (pair? sexp) (eq? (car sexp) 'mes-use-module)) + (loop (mes-load-module-env (cadr sexp) a))) + (else + (let ((e (eval sexp a))) + (if (eq? e *unspecified*) (loop a) + (let ((id (string->symbol (string-append "$" (number->string count))))) + (set! count (+ count 1)) + (display id) + (display " = ") + (display e) + (newline) + (loop (acons id e a)))))))) + (lambda (key . args) + (format (current-error-port) "exception: ~a ~a\n" key args) + (loop a))))))))