diff --git a/src/babashka/impl/cli.clj b/src/babashka/impl/cli.clj index 7a152fc2..1ec08daf 100644 --- a/src/babashka/impl/cli.clj +++ b/src/babashka/impl/cli.clj @@ -17,6 +17,8 @@ (let [extra-opts '%s sym `%s 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) ns (:ns (meta the-var)) ns-meta (meta ns) diff --git a/test/babashka/exec_test.clj b/test/babashka/exec_test.clj index 960de5fa..69d13659 100644 --- a/test/babashka/exec_test.clj +++ b/test/babashka/exec_test.clj @@ -11,6 +11,8 @@ (deftest exec-test (is (= {:foo 1} (edn/read-string (bb "-x" "prn" "--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 (edn/read-string (bb "--prn" "-x" "cheshire.core/generate-string" "--foo" "1")) true))))