Fork me on GitHub
#babashka
<
2020-01-01
>
borkdude22:01:50

A little spec in bb, as a lib (WIP) 🙂

nate_clojurians23:01:07

it would be nice to have clojure.stacktrace -- some of the errors in the repl are not so helpful

nate_clojurians23:01:11

nate.babashka.fs=> (directory? "asdf")
/Users/nsutton/Code/nate.babashka.fs/asdf [at /Users/nsutton/Code/nate.babashka.fs/script/repl.bb, line 94, column 3]

nate_clojurians23:01:31

nate.babashka.fs=> (try (directory? "asdf") (catch Exception e (prn e)))
#error {
 :cause "/Users/nsutton/Code/nate.babashka.fs/asdf"
 :via
 [{:type clojure.lang.ExceptionInfo
   :message "/Users/nsutton/Code/nate.babashka.fs/asdf [at /Users/nsutton/Code/nate.babashka.fs/script/repl.bb, line 94, column 3]"
   :data {:type :sci/error, :row 94, :col 3, :message "/Users/nsutton/Code/nate.babashka.fs/asdf [at /Users/nsutton/Code/nate.babashka.fs/script/repl.bb, line 94, column 3]"}
   :at [sci.impl.utils$rethrow_with_location_of_node invokeStatic "utils.cljc" 71]}
  {:type java.nio.file.NoSuchFileException
   :message "/Users/nsutton/Code/nate.babashka.fs/asdf"
   :at [sun.nio.fs.UnixFileAttributeViews$Basic readAttributes "UnixFileAttributeViews.java" 55]}]

nate_clojurians23:01:41

the root cause is the helpful bit

nate_clojurians23:01:49

and having root-cause would be handy

nate_clojurians23:01:11

I don't know if that happens at runtime, too

borkdude23:01:13

fwiw clojure.stacktrace is already in babashka, but not exposed. could easily be added

nate_clojurians23:01:29

cool, want me to try?

borkdude23:01:36

also the exceptions could probably be improved as well, somehow. not sure how

nate_clojurians23:01:15

in development which jdk should I be using?

borkdude23:01:15

if you have any useful notes for development, you can add them to the README in the "developing babashka" section

nate_clojurians23:01:59

I didn't clone recursive... picard-facepalm

borkdude23:01:06

I made an enhancement to deps.clj. Now you can do this:

{:aliases
 {:test
  {:extra-paths ["test"]
   :extra-deps {borkdude/spartan.test {:mvn/version "0.0.4"}}
   :main-opts ["-m" "spartan.test" "-n" "borkdude.deps-test"]}}}

$ alias babashka='deps.clj -Scommand "bb -cp {{classpath}} {{main-opts}}"'
$ babashka -A:test
Ran 3 tests containing 3 assertions.
0 failures, 0 errors.
$ babashka -e '(+ 1 2 3)'
6

nate_clojurians23:01:09

it looks like the clojure.stacktrace change needs to be added to sci?

borkdude23:01:08

No, not really. You can add it to only babashka

borkdude23:01:21

check out the main.clj namespaces and you'll find many other things that are only added to babashka

borkdude23:01:03

Note that there is a babashka/impl/clojure/stacktrace.clj which you should be using

nate_clojurians23:01:05

turns out stacktraces is pretty significantly different between clj and cljs

borkdude23:01:07

not the normal Clojure one

borkdude23:01:38

the normal one had reflection issues (made a patch in JIRA for that)

borkdude23:01:55

I'm afk now, sleeping