From: David Vázquez Date: Sat, 22 Feb 2014 02:16:10 +0000 (+0100) Subject: Stop propagating errors at toplevel X-Git-Url: http://repo.macrolet.net/gitweb/?p=jscl.git;a=commitdiff_plain;h=81003ba7f1fcb0d2e4232433665725f9286a958e Stop propagating errors at toplevel --- diff --git a/src/toplevel.lisp b/src/toplevel.lisp index 3c38003..9d6594b 100644 --- a/src/toplevel.lisp +++ b/src/toplevel.lisp @@ -264,9 +264,23 @@ (#j:jqconsole:Write prompt "jqconsole-prompt")) (flet ((process-input (input) (let* ((form (read-from-string input)) - (result (multiple-value-list (eval-interactive form)))) - (dolist (x result) - (#j:jqconsole:Write (format nil "~S~%" x) "jqconsole-return")) + (successp nil) + result) + ;; Capture errors. We evaluate the form and set successp + ;; to T. However, if a non-local exist happens, we cancel + ;; it, so it is not propagated more. + (block nil + (unwind-protect + (progn + (setq result (multiple-value-list (eval-interactive form))) + (setq successp t)) + (return))) + + (if successp + (dolist (x result) + (#j:jqconsole:Write (format nil "~S~%" x) "jqconsole-return")) + (#j:jqconsole:Write (format nil "Error occurred~%") "jqconsole-error")) + (save-history)) (toplevel))) (#j:jqconsole:Prompt t #'process-input)))