Skip to content

Commit

Permalink
[babashka#1116] Missing error message when exception happens in REPL …
Browse files Browse the repository at this point in the history
…print
  • Loading branch information
borkdude committed Dec 29, 2021
1 parent 818f2a9 commit ddf03c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/babashka/impl/clojure/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,12 @@ by default when a new command-line REPL is started."} repl-requires
(set! *3 *2)
(set! *2 *1)
(set! *1 value)
(try
(print value)
(catch Throwable e
(throw (ex-info nil {:clojure.error/phase :print-eval-result} e)))))))
(try (print value)
(catch Throwable e
(throw (ex-info (ex-message e)
(assoc (meta input)
:file "<repl>"
:type :sci/error) e)))))))
(catch Throwable e
(caught e)
(set! *e e))))]
Expand Down
4 changes: 3 additions & 1 deletion test/babashka/impl/repl_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
(assert-repl "(read-line)hello" "hello")
(assert-repl "(read-line)\nhello" "hello")
(assert-repl-error "(+ 1 nil)" "NullPointerException")
(assert-repl-error "(/ 1 0) (pst 1)" "Divide by zero\n\tclojure.lang.Numbers"))
(assert-repl-error "(/ 1 0) (pst 1)" "Divide by zero\n\tclojure.lang.Numbers")
(assert-repl-error "(partition (range 5) 3)"
"Don't know how to create ISeq from: java.lang.Long"))

;;;; Scratch

Expand Down

0 comments on commit ddf03c5

Please sign in to comment.