[#221] print name of exception

This commit is contained in:
Michiel Borkent 2020-01-12 17:40:41 +01:00
parent 8e24744d35
commit 19767b54a3
2 changed files with 7 additions and 1 deletions

View file

@ -247,7 +247,9 @@ Everything after that is bound to *command-line-args*."))
(if exit-code [nil exit-code]
(do (if verbose?
(print-stack-trace e)
(println (.getMessage e)))
(println (str (.. e getClass getName)
(when-let [m (.getMessage e)]
(str ": " m)) )))
(flush)
[nil 1])))))

View file

@ -21,6 +21,10 @@
(is (thrown-with-msg? Exception #"does not exist" (bb nil "foo.clj")))
(is (thrown-with-msg? Exception #"does not exist" (bb nil "-help")))))
(deftest print-error-test
(is (thrown-with-msg? Exception #"java.lang.NullPointerException"
(bb nil "(subs nil 0 0)"))))
(deftest main-test
(testing "-io behaves as identity"
(= "foo\nbar\n" (test-utils/bb "foo\nbar\n" "-io" "*input*")))