I'm using clojure with lein. Executing a function from repl gives the following error message:
ClassCastException java.lang.Long cannot be cast to clojure.lang.IFn user/eval3873/fn--3874 (form-init6374407951848346782.clj:1)
So somewhere in the code a long is placed where there's supposed to be a function. But I can't figure out the location of the error in my code
. Is there a way I could get the repl to print the full stack trace of the exception?
Just examine the special variable *e
which is also described in your REPL introduction banner.
For example:
Clojure 1.8.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_161-b12
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e
user=> (+ 1 "r")
ClassCastException java.lang.String cannot be cast to java.lang.Number clojure.lang.Numbers.add (Numbers.java:128)
user=> *e
#error {
:cause "java.lang.String cannot be cast to java.lang.Number"
:via
[{:type java.lang.ClassCastException
:message "java.lang.String cannot be cast to java.lang.Number"
:at [clojure.lang.Numbers add "Numbers.java" 128]}]
:trace
[[clojure.lang.Numbers add "Numbers.java" 128]
[clojure.lang.Numbers add "Numbers.java" 3640]
[user$eval1244 invokeStatic "form-init8915652650489400713.clj" 1]
[user$eval1244 invoke "form-init8915652650489400713.clj" 1]
[clojure.lang.Compiler eval "Compiler.java" 6927]
[clojure.lang.Compiler eval "Compiler.java" 6890]
[clojure.core$eval invokeStatic "core.clj" 3105]
[clojure.core$eval invoke "core.clj" 3101]
[clojure.main$repl$read_eval_print__7408$fn__7411 invoke "main.clj" 240]
[clojure.main$repl$read_eval_print__7408 invoke "main.clj" 240]
[clojure.main$repl$fn__7417 invoke "main.clj" 258]
[clojure.main$repl invokeStatic "main.clj" 258]
[clojure.main$repl doInvoke "main.clj" 174]
[clojure.lang.RestFn invoke "RestFn.java" 1523]
[clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__648 invoke "interruptible_eval.clj" 87]
[clojure.lang.AFn applyToHelper "AFn.java" 152]
[clojure.lang.AFn applyTo "AFn.java" 144]
[clojure.core$apply invokeStatic "core.clj" 646]
[clojure.core$with_bindings_STAR_ invokeStatic "core.clj" 1881]
[clojure.core$with_bindings_STAR_ doInvoke "core.clj" 1881]
[clojure.lang.RestFn invoke "RestFn.java" 425]
[clojure.tools.nrepl.middleware.interruptible_eval$evaluate invokeStatic "interruptible_eval.clj" 85]
[clojure.tools.nrepl.middleware.interruptible_eval$evaluate invoke "interruptible_eval.clj" 55]
[clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__693$fn__696 invoke "interruptible_eval.clj" 222]
[clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__688 invoke "interruptible_eval.clj" 190]
[clojure.lang.AFn run "AFn.java" 22]
[java.util.concurrent.ThreadPoolExecutor runWorker "ThreadPoolExecutor.java" 1149]
[java.util.concurrent.ThreadPoolExecutor$Worker run "ThreadPoolExecutor.java" 624]
[java.lang.Thread run "Thread.java" 748]]}
user=>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With