Re: (type ...) vs (class ...)
Reviving this thread, as I'd like to kmow if someone can explain the purpose of the type metadata and what is responsible for adding it? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: (type ...) vs (class ...)
Looks like pre defrecord stuff used in early days to add "type" to map. Can still be used if you need "type" on a map without using defrecord. среда, 24 октября 2018 г., 10:30:14 UTC+3 пользователь Didier написал: > > Reviving this thread, as I'd like to kmow if someone can explain the > purpose of the type metadata and what is responsible for adding it? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: (type ...) vs (class ...)
the type function in clojure.core lets you override the nominal class of an object with the :type metadata user=> (type {}) clojure.lang.PersistentArrayMap user=> (type ^{:type :foo} {}) :foo On Wed, Oct 24, 2018 at 9:41 AM alex wrote: > Looks like pre defrecord stuff used in early days to add "type" to map. > Can still be used if you need "type" on a map without using defrecord. > > среда, 24 октября 2018 г., 10:30:14 UTC+3 пользователь Didier написал: > >> Reviving this thread, as I'd like to kmow if someone can explain the >> purpose of the type metadata and what is responsible for adding it? > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: (type ...) vs (class ...)
Found this: https://groups.google.com/forum/#!searchin/clojure/%22type$20metadata%22%7Csort:date/clojure/LBGsPs2__pQ/oLgx_kgmQxgJ :tag is applied to source forms to communicate type hints to the compiler. :type can be used, by convention, to add 'type names' to runtime data structures that support metadata. The type function will return the :type metadata if present, else the class, making it a handy dispatch function. Neither :tag nor :type are used directly by isa? Rich On Wednesday, October 24, 2018 at 12:30:14 AM UTC-7, Didier wrote: > > Reviving this thread, as I'd like to kmow if someone can explain the > purpose of the type metadata and what is responsible for adding it? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Inconsistent stack traces from the same expression.
I don't understand what is going on here. I'm trying to throw an exception with a cause and sometimes the cause is included in the stacktrace and sometimes it isn't. ~$ clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.10.0-beta4"}}}' Clojure 1.10.0-beta4 user=> (try (/ 1 0) (catch Exception e "caught")) "caught" user=> (try (/ 1 0) (catch Exception e (throw (Exception. "caught and rethrown" e Evaluation error (ArithmeticException) at clojure.lang.Numbers.divide ( Numbers.java:188). Divide by zero user=> (clojure.repl/pst) ArithmeticException Divide by zero clojure.lang.Numbers.divide (Numbers.java:188) clojure.lang.Numbers.divide (Numbers.java:3901) user$eval3.invokeStatic (:2) user$eval3.invoke (:2) clojure.lang.Compiler.eval (Compiler.java:7172) clojure.lang.Compiler.eval (Compiler.java:7135) clojure.core/eval (core.clj:3206) clojure.core/eval (core.clj:3202) clojure.main/repl/read-eval-print--8898/fn--8901 (main.clj:309) clojure.main/repl/read-eval-print--8898 (main.clj:307) clojure.main/repl/fn--8907 (main.clj:332) clojure.main/repl (main.clj:332) nil Same behavior with Clojure 1.8 and 1.9. If I start a REPL via lein, the cause appears: $ lein repl nREPL server started on port 46767 on host 127.0.0.1 - nrepl: //127.0.0.1:46767 REPL-y 0.3.7, nREPL 0.2.12 Clojure 1.8.0 Java HotSpot(TM) 64-Bit Server VM 1.8.0_102-b14 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=> (try (/ 1 0) (catch Exception e (throw (Exception. "caught and rethrown" e ArithmeticException Divide by zero clojure.lang.Numbers.divide (Numbers.java:158) user=> (clojure.repl/pst) java.lang.Exception: caught and rethrown (Unknown Source) user/eval1736 (Unknown Source) user/eval1736 Compiler.java:6927 clojure.lang.Compiler. eval Compiler.java:6890 clojure.lang.Compiler. eval core.clj:3105 clojure.core/eval core.clj:3101 clojure.core/eval main.clj:240 clojure.main/repl[fn] main.clj:240 clojure.main/repl[fn] main.clj:258 clojure.main/repl[fn] main.clj:258 clojure.main/repl main.clj:174 clojure.main/repl RestFn.java:1523 clojure.lang.RestFn. invoke interruptible_eval.clj:87 clojure.tools.nrepl. middleware.interruptible-eval/evaluate[fn] AFn.java:152 clojure.lang.AFn. applyToHelper AFn.java:144 clojure.lang.AFn.applyTo core.clj:646 clojure.core/apply core.clj:1881 clojure.core/with- bindings* core.clj:1881 clojure.core/with- bindings* RestFn.java:425 clojure.lang.RestFn. invoke interruptible_eval.clj:85 clojure.tools.nrepl. middleware.interruptible-eval/evaluate interruptible_eval.clj:55 clojure.tools.nrepl. middleware.interruptible-eval/evaluate interruptible_eval.clj:224 clojure.tools.nrepl. middleware.interruptible-eval/interruptible-eval[fn] interruptible_eval.clj:192 clojure.tools.nrepl. middleware.interruptible-eval/run-next[fn] AFn.java:22 clojure.lang.AFn.run ThreadPoolExecutor.java:1142 java.util.concurrent. ThreadPoolExecutor.runWorker ThreadPoolExecutor.java:617 java.util.concurrent. ThreadPoolExecutor$Worker.run Thread.java:745 java.lang.Thread.run Caused by: java.lang.ArithmeticException: Divide by zero Numbers.java:158 clojure.lang.Numbers. divide Numbers.java:3808 clojure.lang.Numbers. divide nil But if I run lein repl from inside a project directory, the cause is not included: $ lein new test-project Generating a project called test-project based on the 'default' template. The default template is intended for library projects, not applications. To see other templates (app, plugin, etc), try `lein help new`. ~$ cd test-project/ ~/test-project$ lein repl nREPL server started on port 36739 on host 127.0.0.1 - nrepl://127.0.0.1: 36739 REPL-y 0.3.7, nREPL 0.2.12 Clojure 1.8.0 Java HotSpot(TM) 64-Bit Server VM 1.8.0_102-b14 Docs: (doc function-name-here) (find-doc "part-of-name-here") Source: (source function-name-here) Ja
Re: Inconsistent stack traces from the same expression.
I am not sure if this is the reason, but I would recommend checking the command line options used when starting the java process in these cases. Leiningen uses some command line options by default, for faster startup times I think, that might affect how much detail is captured in stack traces when exceptions are created. Andy On Wed, Oct 24, 2018 at 6:53 PM Austin Haas wrote: > I don't understand what is going on here. I'm trying to throw an exception > with a cause and sometimes the cause is included in the stacktrace and > sometimes it isn't. > > ~$ clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version > "1.10.0-beta4"}}}' > Clojure 1.10.0-beta4 > user=> (try (/ 1 0) (catch Exception e "caught")) > "caught" > user=> (try (/ 1 0) (catch Exception e (throw (Exception. "caught and > rethrown" e > Evaluation error (ArithmeticException) at clojure.lang.Numbers.divide ( > Numbers.java:188). > Divide by zero > user=> (clojure.repl/pst) > ArithmeticException Divide by zero > clojure.lang.Numbers.divide (Numbers.java:188) > clojure.lang.Numbers.divide (Numbers.java:3901) > user$eval3.invokeStatic (:2) > user$eval3.invoke (:2) > clojure.lang.Compiler.eval (Compiler.java:7172) > clojure.lang.Compiler.eval (Compiler.java:7135) > clojure.core/eval (core.clj:3206) > clojure.core/eval (core.clj:3202) > clojure.main/repl/read-eval-print--8898/fn--8901 (main.clj:309) > clojure.main/repl/read-eval-print--8898 (main.clj:307) > clojure.main/repl/fn--8907 (main.clj:332) > clojure.main/repl (main.clj:332) > nil > > Same behavior with Clojure 1.8 and 1.9. > > If I start a REPL via lein, the cause appears: > > $ lein repl > nREPL server started on port 46767 on host 127.0.0.1 - nrepl:// > 127.0.0.1:46767 > REPL-y 0.3.7, nREPL 0.2.12 > Clojure 1.8.0 > Java HotSpot(TM) 64-Bit Server VM 1.8.0_102-b14 > 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=> (try (/ 1 0) (catch Exception e (throw (Exception. "caught and > rethrown" e > > > ArithmeticException Divide by zero clojure.lang.Numbers.divide > (Numbers.java:158) > user=> (clojure.repl/pst) > java.lang.Exception: caught and rethrown > (Unknown Source) user/eval1736 > (Unknown Source) user/eval1736 > Compiler.java:6927 clojure.lang.Compiler. > eval > Compiler.java:6890 clojure.lang.Compiler. > eval > core.clj:3105 clojure.core/eval > core.clj:3101 clojure.core/eval > main.clj:240 clojure.main/repl[fn] > main.clj:240 clojure.main/repl[fn] > main.clj:258 clojure.main/repl[fn] > main.clj:258 clojure.main/repl > main.clj:174 clojure.main/repl > RestFn.java:1523 clojure.lang.RestFn. > invoke > interruptible_eval.clj:87 clojure.tools.nrepl. > middleware.interruptible-eval/evaluate[fn] > AFn.java:152 clojure.lang.AFn. > applyToHelper > AFn.java:144 clojure.lang.AFn. > applyTo > core.clj:646 clojure.core/apply > core.clj:1881 clojure.core/with- > bindings* > core.clj:1881 clojure.core/with- > bindings* >RestFn.java:425 clojure.lang.RestFn. > invoke > interruptible_eval.clj:85 clojure.tools.nrepl. > middleware.interruptible-eval/evaluate > interruptible_eval.clj:55 clojure.tools.nrepl. > middleware.interruptible-eval/evaluate > interruptible_eval.clj:224 clojure.tools.nrepl. > middleware.interruptible-eval/interruptible-eval[fn] > interruptible_eval.clj:192 clojure.tools.nrepl. > middleware.interruptible-eval/run-next[fn] >AFn.java:22 clojure.lang.AFn.run > ThreadPoolExecutor.java:1142 java.util.concurrent. > ThreadPoolExecutor.runWorker >ThreadPoolExecutor.java:617 java.util.concurrent. > ThreadPoolExecutor$Worker.run >Thread.java:745 java.lang.Thread.run > Caused by: java.lang.ArithmeticException: Divide by zero > Numbers.java:158 clojure.lang.Numbers. > divide > Numbers.java:3808 clojure.lang.Numbers. > divide > nil > > But if I run lein repl from inside a project directory, the cause is n
Re: Inconsistent stack traces from the same expression.
Thanks. I would not have thought to check that. These are the processes running after launching each REPL. $ clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.10.0-beta4"}}}' Does not include cause. rlwrap -r -q \" -b (){}[],^%3@";:' clojure -Sdeps {:deps {org.clojure/clojure {:mvn/version "1.10.0-beta4"}}} /usr/bin/java -Dclojure.libfile=/home/austin/.clojure/.cpcache/638968264.libs -classpath src:/home/austin/.m2/repository/org/clojure/clojure/1.10.0-beta4/clojure-1.10.0-beta4.jar:/home/austin/.m2/repository/org/clojure/spec.alpha/0.2.176/spec.alpha-0.2.176.jar:/home/austin/.m2/repository/org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar clojure.main $ lein repl Includes cause. java -Dfile.encoding=UTF-8 -Dmaven.wagon.http.ssl.easy=false -Dmaven.wagon.rto=1 -Xverify:none -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Dleiningen.original.pwd=/home/austin -Dleiningen.script=/home/austin/bin/lein -classpath /home/austin/.lein/self-installs/leiningen-2.8.1-standalone.jar clojure.main -m leiningen.core.main repl $ lein repl (inside project) Does not include cause. java -Dfile.encoding=UTF-8 -Dmaven.wagon.http.ssl.easy=false -Dmaven.wagon.rto=1 -Xverify:none -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Dleiningen.original.pwd=/home/austin/test-project -Dleiningen.script=/home/austin/bin/lein -classpath /home/austin/.lein/self-installs/leiningen-2.8.1-standalone.jar clojure.main -m leiningen.core.main repl java -classpath /home/austin/test-project/test:/home/austin/test-project/src:/home/austin/test-project/dev-resources:/home/austin/test-project/resources:/home/austin/test-project/target/classes:/home/austin/.m2/repository/org/clojure/clojure/1.8.0/clojure-1.8.0.jar:/home/austin/.m2/repository/org/clojure/tools.nrepl/0.2.12/tools.nrepl-0.2.12.jar:/home/austin/.m2/repository/clojure-complete/clojure-complete/0.2.4/clojure-complete-0.2.4.jar -Dfile.encoding=UTF-8 -XX:-OmitStackTraceInFastThrow -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Dclojure.compile.path=/home/austin/test-project/target/classes -Dtest-project.version=0.1.0-SNAPSHOT -Dclojure.debug=false clojure.main -i /tmp/form-init3009346480080427936.clj I'm not sure what to make of this. I don't see anything unusual, but I have limited experience with Java. Why does running `lein repl` in a project directory start two processes? -austin On Wednesday, October 24, 2018 at 7:40:28 PM UTC-7, Andy Fingerhut wrote: > > I am not sure if this is the reason, but I would recommend checking the > command line options used when starting the java process in these cases. > Leiningen uses some command line options by default, for faster startup > times I think, that might affect how much detail is captured in stack > traces when exceptions are created. > > Andy > > On Wed, Oct 24, 2018 at 6:53 PM Austin Haas > wrote: > >> I don't understand what is going on here. I'm trying to throw an >> exception with a cause and sometimes the cause is included in the >> stacktrace and sometimes it isn't. >> >> ~$ clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version >> "1.10.0-beta4"}}}' >> Clojure 1.10.0-beta4 >> user=> (try (/ 1 0) (catch Exception e "caught")) >> "caught" >> user=> (try (/ 1 0) (catch Exception e (throw (Exception. "caught and >> rethrown" e >> Evaluation error (ArithmeticException) at clojure.lang.Numbers.divide ( >> Numbers.java:188). >> Divide by zero >> user=> (clojure.repl/pst) >> ArithmeticException Divide by zero >> clojure.lang.Numbers.divide (Numbers.java:188) >> clojure.lang.Numbers.divide (Numbers.java:3901) >> user$eval3.invokeStatic (:2) >> user$eval3.invoke (:2) >> clojure.lang.Compiler.eval (Compiler.java:7172) >> clojure.lang.Compiler.eval (Compiler.java:7135) >> clojure.core/eval (core.clj:3206) >> clojure.core/eval (core.clj:3202) >> clojure.main/repl/read-eval-print--8898/fn--8901 (main.clj:309) >> clojure.main/repl/read-eval-print--8898 (main.clj:307) >> clojure.main/repl/fn--8907 (main.clj:332) >> clojure.main/repl (main.clj:332) >> nil >> >> Same behavior with Clojure 1.8 and 1.9. >> >> If I start a REPL via lein, the cause appears: >> >> $ lein repl >> nREPL server started on port 46767 on host 127.0.0.1 - nrepl:// >> 127.0.0.1:46767 >> REPL-y 0.3.7, nREPL 0.2.12 >> Clojure 1.8.0 >> Java HotSpot(TM) 64-Bit Server VM 1.8.0_102-b14 >> 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=> (try (/ 1 0) (catch Exception e (throw (Exception. "caught and >> rethrown" e >> >> >> ArithmeticException Divide by zero clojure.lang.Numbers.divide >> (Numbers.java:158) >> user=> (clojure.repl/pst) >> java.lang.Exception: caught and rethrown >> (Unknown Source) user/eval1736 >>
Re: Inconsistent stack traces from the same expression.
Re clj / the built-in repl: user=> (doc pst) - clojure.repl/pst ([] [e-or-depth] [e depth]) Prints a stack trace of the exception, to the depth requested. If none supplied, *uses the root cause* of the most recent repl exception (*e), and a depth of 12. That is, it only prints the root cause (bottom level) exception in the stack. Leiningen uses its own exception printer and overrides what's in core. I'm not sure where exactly that's done. Perhaps useful for debugging, you can just do *e at the repl - that will evaluate and print the last exception in the *e var. Exceptions have a built-in printer that prints the exception as data and will include the full stack. You can access the same functionality with the core function Throwable->map: (Throwable->map *e) Sometimes useful for investigating the truth of the matter in a consumable way and taking the (possibly customized) repl machinery out of the picture. On Wednesday, October 24, 2018 at 8:52:58 PM UTC-5, Austin Haas wrote: > > I don't understand what is going on here. I'm trying to throw an exception > with a cause and sometimes the cause is included in the stacktrace and > sometimes it isn't. > > ~$ clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version > "1.10.0-beta4"}}}' > Clojure 1.10.0-beta4 > user=> (try (/ 1 0) (catch Exception e "caught")) > "caught" > user=> (try (/ 1 0) (catch Exception e (throw (Exception. "caught and > rethrown" e > Evaluation error (ArithmeticException) at clojure.lang.Numbers.divide ( > Numbers.java:188). > Divide by zero > user=> (clojure.repl/pst) > ArithmeticException Divide by zero > clojure.lang.Numbers.divide (Numbers.java:188) > clojure.lang.Numbers.divide (Numbers.java:3901) > user$eval3.invokeStatic (:2) > user$eval3.invoke (:2) > clojure.lang.Compiler.eval (Compiler.java:7172) > clojure.lang.Compiler.eval (Compiler.java:7135) > clojure.core/eval (core.clj:3206) > clojure.core/eval (core.clj:3202) > clojure.main/repl/read-eval-print--8898/fn--8901 (main.clj:309) > clojure.main/repl/read-eval-print--8898 (main.clj:307) > clojure.main/repl/fn--8907 (main.clj:332) > clojure.main/repl (main.clj:332) > nil > > Same behavior with Clojure 1.8 and 1.9. > > If I start a REPL via lein, the cause appears: > > $ lein repl > nREPL server started on port 46767 on host 127.0.0.1 - nrepl:// > 127.0.0.1:46767 > REPL-y 0.3.7, nREPL 0.2.12 > Clojure 1.8.0 > Java HotSpot(TM) 64-Bit Server VM 1.8.0_102-b14 > 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=> (try (/ 1 0) (catch Exception e (throw (Exception. "caught and > rethrown" e > > > ArithmeticException Divide by zero clojure.lang.Numbers.divide > (Numbers.java:158) > user=> (clojure.repl/pst) > java.lang.Exception: caught and rethrown > (Unknown Source) user/eval1736 > (Unknown Source) user/eval1736 > Compiler.java:6927 clojure.lang.Compiler. > eval > Compiler.java:6890 clojure.lang.Compiler. > eval > core.clj:3105 clojure.core/eval > core.clj:3101 clojure.core/eval > main.clj:240 clojure.main/repl[fn] > main.clj:240 clojure.main/repl[fn] > main.clj:258 clojure.main/repl[fn] > main.clj:258 clojure.main/repl > main.clj:174 clojure.main/repl > RestFn.java:1523 clojure.lang.RestFn. > invoke > interruptible_eval.clj:87 clojure.tools.nrepl. > middleware.interruptible-eval/evaluate[fn] > AFn.java:152 clojure.lang.AFn. > applyToHelper > AFn.java:144 clojure.lang.AFn. > applyTo > core.clj:646 clojure.core/apply > core.clj:1881 clojure.core/with- > bindings* > core.clj:1881 clojure.core/with- > bindings* >RestFn.java:425 clojure.lang.RestFn. > invoke > interruptible_eval.clj:85 clojure.tools.nrepl. > middleware.interruptible-eval/evaluate > interruptible_eval.clj:55 clojure.tools.nrepl. > middleware.interruptible-eval/evaluate > interruptible_eval.clj:224 clojure.tools.nrepl. > middleware.interruptible-eval/interruptible-eval[fn] > interruptible_eval.clj:192 clojure.tools.nrepl. > middleware.interruptible-eval/run-next[fn] >
Re: Inconsistent stack traces from the same expression.
Thanks, Alex. I didn't know about *e or Throwable->map. -austin On Wednesday, October 24, 2018 at 9:07:44 PM UTC-7, Alex Miller wrote: > > Re clj / the built-in repl: > > user=> (doc pst) > - > clojure.repl/pst > ([] [e-or-depth] [e depth]) > Prints a stack trace of the exception, to the depth requested. If none > supplied, *uses the root cause* of the > most recent repl exception (*e), and a depth of 12. > > That is, it only prints the root cause (bottom level) exception in the > stack. > > Leiningen uses its own exception printer and overrides what's in core. I'm > not sure where exactly that's done. > > Perhaps useful for debugging, you can just do *e at the repl - that will > evaluate and print the last exception in the *e var. Exceptions have a > built-in printer that prints the exception as data and will include the > full stack. You can access the same functionality with the core function > Throwable->map: > > (Throwable->map *e) > > Sometimes useful for investigating the truth of the matter in a consumable > way and taking the (possibly customized) repl machinery out of the picture. > > > > > > > On Wednesday, October 24, 2018 at 8:52:58 PM UTC-5, Austin Haas wrote: >> >> I don't understand what is going on here. I'm trying to throw an >> exception with a cause and sometimes the cause is included in the >> stacktrace and sometimes it isn't. >> >> ~$ clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version >> "1.10.0-beta4"}}}' >> Clojure 1.10.0-beta4 >> user=> (try (/ 1 0) (catch Exception e "caught")) >> "caught" >> user=> (try (/ 1 0) (catch Exception e (throw (Exception. "caught and >> rethrown" e >> Evaluation error (ArithmeticException) at clojure.lang.Numbers.divide ( >> Numbers.java:188). >> Divide by zero >> user=> (clojure.repl/pst) >> ArithmeticException Divide by zero >> clojure.lang.Numbers.divide (Numbers.java:188) >> clojure.lang.Numbers.divide (Numbers.java:3901) >> user$eval3.invokeStatic (:2) >> user$eval3.invoke (:2) >> clojure.lang.Compiler.eval (Compiler.java:7172) >> clojure.lang.Compiler.eval (Compiler.java:7135) >> clojure.core/eval (core.clj:3206) >> clojure.core/eval (core.clj:3202) >> clojure.main/repl/read-eval-print--8898/fn--8901 (main.clj:309) >> clojure.main/repl/read-eval-print--8898 (main.clj:307) >> clojure.main/repl/fn--8907 (main.clj:332) >> clojure.main/repl (main.clj:332) >> nil >> >> Same behavior with Clojure 1.8 and 1.9. >> >> If I start a REPL via lein, the cause appears: >> >> $ lein repl >> nREPL server started on port 46767 on host 127.0.0.1 - nrepl:// >> 127.0.0.1:46767 >> REPL-y 0.3.7, nREPL 0.2.12 >> Clojure 1.8.0 >> Java HotSpot(TM) 64-Bit Server VM 1.8.0_102-b14 >> 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=> (try (/ 1 0) (catch Exception e (throw (Exception. "caught and >> rethrown" e >> >> >> ArithmeticException Divide by zero clojure.lang.Numbers.divide >> (Numbers.java:158) >> user=> (clojure.repl/pst) >> java.lang.Exception: caught and rethrown >> (Unknown Source) user/eval1736 >> (Unknown Source) user/eval1736 >> Compiler.java:6927 clojure.lang.Compiler. >> eval >> Compiler.java:6890 clojure.lang.Compiler. >> eval >> core.clj:3105 clojure.core/eval >> core.clj:3101 clojure.core/eval >> main.clj:240 clojure.main/repl[fn] >> main.clj:240 clojure.main/repl[fn] >> main.clj:258 clojure.main/repl[fn] >> main.clj:258 clojure.main/repl >> main.clj:174 clojure.main/repl >> RestFn.java:1523 clojure.lang.RestFn. >> invoke >> interruptible_eval.clj:87 clojure.tools.nrepl. >> middleware.interruptible-eval/evaluate[fn] >> AFn.java:152 clojure.lang.AFn. >> applyToHelper >> AFn.java:144 clojure.lang.AFn. >> applyTo >> core.clj:646 clojure.core/apply >> core.clj:1881 clojure.core/with- >> bindings* >> core.clj:1881 clojure.core/with- >> bindings* >>RestFn.java:425 clojure.lang.RestFn. >> invoke >> interruptible_eval.clj:85 clojure.tools.nrepl. >> middleware.interruptible-eval/evaluate >> interruptible_eval.clj:55 clojure.tools.nrepl. >> middleware