#1410: better error message when exec fn doesn't exist
This commit is contained in:
parent
2166c42de2
commit
b337e032b6
2 changed files with 4 additions and 0 deletions
|
|
@ -17,6 +17,8 @@
|
||||||
(let [extra-opts '%s
|
(let [extra-opts '%s
|
||||||
sym `%s
|
sym `%s
|
||||||
the-var (requiring-resolve sym)
|
the-var (requiring-resolve sym)
|
||||||
|
_ (when-not the-var
|
||||||
|
(throw (ex-info (str \"Could not resolve sym to a function: \" sym) {:babashka/exit 1})))
|
||||||
the-var-meta (meta the-var)
|
the-var-meta (meta the-var)
|
||||||
ns (:ns (meta the-var))
|
ns (:ns (meta the-var))
|
||||||
ns-meta (meta ns)
|
ns-meta (meta ns)
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@
|
||||||
(deftest exec-test
|
(deftest exec-test
|
||||||
(is (= {:foo 1} (edn/read-string (bb "-x" "prn" "--foo" "1"))))
|
(is (= {:foo 1} (edn/read-string (bb "-x" "prn" "--foo" "1"))))
|
||||||
(is (thrown? Exception (bb "-x" "json/generate-string" "--foo" "1")))
|
(is (thrown? Exception (bb "-x" "json/generate-string" "--foo" "1")))
|
||||||
|
(is (thrown-with-msg? Exception #"Could not resolve sym to a function: clojure.core/generate-string"
|
||||||
|
(bb "-x" "clojure.core/generate-string" "--foo" "1")))
|
||||||
(is (= {:foo 1} (cheshire/parse-string
|
(is (= {:foo 1} (cheshire/parse-string
|
||||||
(edn/read-string
|
(edn/read-string
|
||||||
(bb "--prn" "-x" "cheshire.core/generate-string" "--foo" "1")) true))))
|
(bb "--prn" "-x" "cheshire.core/generate-string" "--foo" "1")) true))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue