<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions in Errors</title>
<link>https://ask.clojure.org/index.php/questions/clojure/errors</link>
<description></description>
<item>
<title>&quot;Nested&quot; vs &quot;lateral&quot; exception causes</title>
<link>https://ask.clojure.org/index.php/15031/nested-vs-lateral-exception-causes</link>
<description>&lt;p&gt;Currently, &lt;code&gt;clojure.core/ex-info&lt;/code&gt; must take a &lt;code&gt;msg&lt;/code&gt; and data &lt;code&gt;map&lt;/code&gt;, and may take a &lt;code&gt;cause&lt;/code&gt;, which must be another &lt;code&gt;Throwable&lt;/code&gt;, which may have its own &lt;code&gt;cause&lt;/code&gt;, etc. etc..&lt;/p&gt;
&lt;p&gt;This supports the case of &quot;nested&quot; exceptions quite well, e.g. in the case of compilation exceptions being caused by macroexpansion exceptions, potentially with their own cause, and works well for fail-on-first-problem situations.&lt;/p&gt;
&lt;p&gt;There's also the situation of &quot;lateral&quot; exceptions, e.g. in the case of test runners or static analysers, which is not supported. In this case, if we take &lt;code&gt;lazytest&lt;/code&gt; as a concrete example, the test runner throws an exception if any of the test cases it runs throws an exception, but the overall cause of the overall exception, conceptually, is &lt;em&gt;all&lt;/em&gt; the individual exceptions.&lt;/p&gt;
&lt;p&gt;Currently, the only to do this is to make some bespoke thing in the data &lt;code&gt;map&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;I propose changing &lt;code&gt;clojure.core/ex-info&lt;/code&gt; to take &lt;code&gt;[msg map &amp;amp; causes]&lt;/code&gt;, which would be a non-breaking change (or, while we're at it, make the &lt;code&gt;map&lt;/code&gt; arg optional as well and default it to &lt;code&gt;{}&lt;/code&gt;, but that's a separate topic).&lt;/p&gt;
&lt;p&gt;That leaves the question of how to handle &lt;code&gt;ex-cause&lt;/code&gt;. To my understanding, to change it to return the cause or the list of causes, would maybe be a breaking change for general exception handling libraries or something, but would not imo pose any significant problem. Alternatively, we might have &lt;code&gt;ex-causes&lt;/code&gt; to always return a list, and change &lt;code&gt;ex-cause&lt;/code&gt; to &lt;code&gt;(comp first ex-causes)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Any thoughts? I don't trust myself to spearhead a PR alone on this but I'd love to contribute, certainly the pure-clojure side of things seems straightforward enough (and I'd love to patch this into &lt;code&gt;lazytest&lt;/code&gt;, but that's again a different topic).&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/15031/nested-vs-lateral-exception-causes</guid>
<pubDate>Sun, 05 Apr 2026 14:18:26 +0000</pubDate>
</item>
<item>
<title>`(even? (range))` hangs</title>
<link>https://ask.clojure.org/index.php/14578/even-range-hangs</link>
<description>&lt;p&gt;It is, of course, an error to call &lt;code&gt;(even? (range))&lt;/code&gt;, but still - I'd much rather prefer a class cast exception. Or the existing &lt;code&gt;IllegalArgumentException&lt;/code&gt;, just without printing the argument. Especially given that the argument could be absolutely anything, including side-effecting lazy collections.&lt;/p&gt;
&lt;p&gt;A couple of other cases like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(array-map (range))
(requiring-resolve (range))
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14578/even-range-hangs</guid>
<pubDate>Sun, 08 Jun 2025 11:54:29 +0000</pubDate>
</item>
<item>
<title>Should 'method value' error messages (wrong arity) special case for constructors?</title>
<link>https://ask.clojure.org/index.php/13707/should-method-value-error-messages-wrong-special-constructors</link>
<description>&lt;p&gt;If I call a method with the wrong number of arguments, I get a concise, descriptive error message:&lt;br&gt;
&lt;code&gt;(^[] String/toUpperCase &quot;foo&quot; 2)
Syntax error...
Invocation of method toUpperCase in class java.lang.String expected 0 arguments, but received 1&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;If I call a constructor with the wrong number of arguments, I get a very similar message:&lt;br&gt;
&lt;code&gt;(^[String] String/new &quot;foo&quot; 2)
Syntax error...
Invocation of method java.lang.String in class java.lang.String expected 1 arguments, but received 2&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This message refers to the class name as the method, which feels like what you might get for a constructor.&lt;/p&gt;
&lt;p&gt;I noticed that if my param-tags are incorrect on a constructor, the wording of the message is slightly different (&quot;Expected to find 1 matching signature for &lt;em&gt;constructor&lt;/em&gt;&quot; as opposed to &quot;for &lt;em&gt;method&lt;/em&gt;&quot;), so I just want to pose the question while these messages are somewhat fresh: Should the wording for the arity message mention 'constructor' or 'String/new' or something along those lines?&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13707/should-method-value-error-messages-wrong-special-constructors</guid>
<pubDate>Mon, 12 Feb 2024 23:36:52 +0000</pubDate>
</item>
<item>
<title>Wrong line number reported for exceptions thrown by code generated by destructuring</title>
<link>https://ask.clojure.org/index.php/13605/number-reported-exceptions-thrown-generated-destructuring</link>
<description>&lt;p&gt;Put anywhere in &lt;code&gt;bad_line_number.clj&lt;/code&gt;, run with &lt;code&gt;clj -J-Dclojure.main.report=stderr -Sdeps '{:paths [&quot;.&quot;]}' -M -m bad-line-number&lt;/code&gt; from the same dir.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns bad-line-number)

(defn returns-a-tuple []
  [{1 2} :wrapped])

(defn should-also-return-a-tuple-but-doesnt [data]
  {data :unwrapped})

(defn -main []
  (let [[a fmt] (returns-a-tuple)
        data
        (try
          (should-also-return-a-tuple-but-doesnt a)
          (catch Throwable _
            (println &quot;Unable to create a map&quot;)
            [3 4]))

        [x y]
        (case fmt
          :wrapped data
          :unwrapped [data nil])]
    [x y]))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Running that code results in &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{:clojure.main/message
 &quot;Execution error (UnsupportedOperationException) at bad-line-number/-main (bad_line_number.clj:10).\nnth not supported on this type: PersistentArrayMap\n&quot;,
 :clojure.main/triage
 {:clojure.error/class java.lang.UnsupportedOperationException,
  :clojure.error/line 10,
  :clojure.error/cause
  &quot;nth not supported on this type: PersistentArrayMap&quot;,
  :clojure.error/symbol bad-line-number/-main,
  :clojure.error/source &quot;bad_line_number.clj&quot;,
  :clojure.error/phase :execution},
 :clojure.main/trace
 {:via
  [{:type java.lang.UnsupportedOperationException,
    :message &quot;nth not supported on this type: PersistentArrayMap&quot;,
    :at [clojure.lang.RT nthFrom &quot;RT.java&quot; 992]}],
  :trace
  [[clojure.lang.RT nthFrom &quot;RT.java&quot; 992]
   [clojure.lang.RT nth &quot;RT.java&quot; 940]
   [bad_line_number$_main invokeStatic &quot;bad_line_number.clj&quot; 10]
   [bad_line_number$_main invoke &quot;bad_line_number.clj&quot; 9]
   [clojure.lang.AFn applyToHelper &quot;AFn.java&quot; 152]
   [clojure.lang.AFn applyTo &quot;AFn.java&quot; 144]
   [clojure.lang.Var applyTo &quot;Var.java&quot; 705]
   [clojure.core$apply invokeStatic &quot;core.clj&quot; 667]
   [clojure.main$main_opt invokeStatic &quot;main.clj&quot; 514]
   [clojure.main$main_opt invoke &quot;main.clj&quot; 510]
   [clojure.main$main invokeStatic &quot;main.clj&quot; 664]
   [clojure.main$main doInvoke &quot;main.clj&quot; 616]
   [clojure.lang.RestFn applyTo &quot;RestFn.java&quot; 137]
   [clojure.lang.Var applyTo &quot;Var.java&quot; 705]
   [clojure.main main &quot;main.java&quot; 40]],
  :cause &quot;nth not supported on this type: PersistentArrayMap&quot;}}

Execution error (UnsupportedOperationException) at bad-line-number/-main (bad_line_number.clj:10).
nth not supported on this type: PersistentArrayMap
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, it refers to line 10, which has &lt;code&gt;(let [[a fmt] (returns-a-tuple)&lt;/code&gt;, so naturally the first line of thinking is &quot;&lt;code&gt;returns-a-tuple&lt;/code&gt; somehow returns a map, and that's what I need to investigate&quot;.&lt;br&gt;
Just spent a few hours chasing that goose when it's actually &lt;code&gt;should-also-return-a-tuple-but-doesnt&lt;/code&gt; that's to blame.&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13605/number-reported-exceptions-thrown-generated-destructuring</guid>
<pubDate>Sat, 06 Jan 2024 10:56:33 +0000</pubDate>
</item>
<item>
<title>`ClassCastException` when misplacing `nth` args</title>
<link>https://ask.clojure.org/index.php/13539/classcastexception-when-misplacing-nth-args</link>
<description>&lt;p&gt;I accidentally misplaced the args to &lt;code&gt;nth&lt;/code&gt; and was presented with the following error and stacktrace:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  Show: Project-Only All 
  Hide: Clojure Java REPL Tooling Duplicates  (0 frames hidden)

2. Unhandled clojure.lang.Compiler$CompilerException
   Error compiling NO_SOURCE_FILE at (79:3)
   #:clojure.error{:phase :execution,
                   :line 79,
                   :column 3,
                   :source &quot;NO_SOURCE_FILE&quot;}
             Compiler.java: 3719  clojure.lang.Compiler$InvokeExpr/eval
             Compiler.java:  457  clojure.lang.Compiler$DefExpr/eval
             Compiler.java: 7199  clojure.lang.Compiler/eval
             Compiler.java: 7149  clojure.lang.Compiler/eval
                  core.clj: 3215  clojure.core/eval
                  core.clj: 3211  clojure.core/eval
    interruptible_eval.clj:   87  nrepl.middleware.interruptible-eval/evaluate/fn/fn
                  AFn.java:  152  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  667  clojure.core/apply
                  core.clj: 1990  clojure.core/with-bindings*
                  core.clj: 1990  clojure.core/with-bindings*
               RestFn.java:  425  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   87  nrepl.middleware.interruptible-eval/evaluate/fn
                  main.clj:  437  clojure.main/repl/read-eval-print/fn
                  main.clj:  437  clojure.main/repl/read-eval-print
                  main.clj:  458  clojure.main/repl/fn
                  main.clj:  458  clojure.main/repl
                  main.clj:  368  clojure.main/repl
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   84  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:   56  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  152  nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
                  AFn.java:   22  clojure.lang.AFn/run
               session.clj:  202  nrepl.middleware.session/session-exec/main-loop/fn
               session.clj:  201  nrepl.middleware.session/session-exec/main-loop
                  AFn.java:   22  clojure.lang.AFn/run
               Thread.java:  829  java.lang.Thread/run

1. Caused by java.lang.ClassCastException
   class clojure.lang.PersistentVector cannot be cast to class
   java.lang.Number (clojure.lang.PersistentVector is in unnamed module of
   loader 'app'; java.lang.Number is in module java.base of loader
   'bootstrap')

                      REPL:   82  advent-of-clerk.year-2023.day-04/fn
                      REPL:   79  advent-of-clerk.year-2023.day-04/fn
                  AFn.java:  152  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
             Compiler.java: 3714  clojure.lang.Compiler$InvokeExpr/eval
             Compiler.java:  457  clojure.lang.Compiler$DefExpr/eval
             Compiler.java: 7199  clojure.lang.Compiler/eval
             Compiler.java: 7149  clojure.lang.Compiler/eval
                  core.clj: 3215  clojure.core/eval
                  core.clj: 3211  clojure.core/eval
    interruptible_eval.clj:   87  nrepl.middleware.interruptible-eval/evaluate/fn/fn
                  AFn.java:  152  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  667  clojure.core/apply
                  core.clj: 1990  clojure.core/with-bindings*
                  core.clj: 1990  clojure.core/with-bindings*
               RestFn.java:  425  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   87  nrepl.middleware.interruptible-eval/evaluate/fn
                  main.clj:  437  clojure.main/repl/read-eval-print/fn
                  main.clj:  437  clojure.main/repl/read-eval-print
                  main.clj:  458  clojure.main/repl/fn
                  main.clj:  458  clojure.main/repl
                  main.clj:  368  clojure.main/repl
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   84  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:   56  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  152  nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
                  AFn.java:   22  clojure.lang.AFn/run
               session.clj:  202  nrepl.middleware.session/session-exec/main-loop/fn
               session.clj:  201  nrepl.middleware.session/session-exec/main-loop
                  AFn.java:   22  clojure.lang.AFn/run
               Thread.java:  829  java.lang.Thread/run
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I was having a hard time spotting the problem, as I was changing a few things at once.  Ultimately I realized that I've misplaced the collection and the index arguments to &lt;code&gt;nth&lt;/code&gt;, but the stacktrace did little to help me realize that: there is no mention of call to &lt;code&gt;nth&lt;/code&gt; there, and the line numbers are not pointing exactly to the problematic line.&lt;/p&gt;
&lt;p&gt;The complete example code here: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/a1exsh/advent-of-clerk/blob/cddd42fcd60da2efcda37f222666328cd37fb616/src/advent_of_clerk/year_2023/day_04.clj#L84&quot;&gt;https://github.com/a1exsh/advent-of-clerk/blob/cddd42fcd60da2efcda37f222666328cd37fb616/src/advent_of_clerk/year_2023/day_04.clj#L84&lt;/a&gt; (this is the correct code — to get the error swap the arguments like this: &lt;code&gt;(nth i untouched)&lt;/code&gt;)&lt;/p&gt;
&lt;p&gt;The environment where I was hitting this is evaluating the single loop form in CIDER (Emacs) with &lt;code&gt;C-x C-e&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;It can be readily reproduced in REPL of course, just like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user&amp;gt; (nth 0 [])
Execution error (ClassCastException) at user/eval22783 (REPL:42).
class clojure.lang.PersistentVector cannot be cast to class java.lang.Number (clojure.lang.PersistentVector is in unnamed module of loader 'app'; java.lang.Number is in module java.base of loader 'bootstrap')
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13539/classcastexception-when-misplacing-nth-args</guid>
<pubDate>Mon, 11 Dec 2023 05:42:28 +0000</pubDate>
</item>
<item>
<title>How can tools better detect errors coming from non-existing methods/fields?</title>
<link>https://ask.clojure.org/index.php/13339/tools-better-detect-errors-coming-existing-methods-fields</link>
<description>&lt;p&gt;&lt;code&gt;(.a &quot;&quot;)&lt;/code&gt;, rightfully, throws an IllegalArgumentException without a &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.org/reference/repl_and_main#_at_repl&quot;&gt;:phase&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;One can consider, however, that this IllegalArgumentException is &quot;compiler-like&quot;, while it doesn't seem primarily distinguishable of other IllegalArgumentExceptions that may be thrown in more &quot;runtime-like&quot; situations.&lt;/p&gt;
&lt;p&gt;My problem is that, as a tool maker, without such a distinction, all IllegalArgumentExceptions will be given the same treatment, while users would want a more concise treatment (e.g. no stacktraces shown) for compiler-like ones.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Is there a recommended way to inspect runtime exceptions for determining if they represent something that, from the user point of view, represents &quot;code that is invalid to begin with&quot;?&lt;ul&gt;
&lt;li&gt;(this is an informal term to describe runtime exceptions that are compiler-like)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Has it been considered to make this easier by e.g. attaching a &lt;code&gt;:cause&lt;/code&gt; (or &lt;code&gt;:phase&lt;/code&gt;, &lt;code&gt;:ex-data&lt;/code&gt;, something) when the Clojure compiler/runtime can reliably do so?&lt;/li&gt;
&lt;/ul&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13339/tools-better-detect-errors-coming-existing-methods-fields</guid>
<pubDate>Thu, 28 Sep 2023 09:43:19 +0000</pubDate>
</item>
<item>
<title>Null pointer error when using filter</title>
<link>https://ask.clojure.org/index.php/13302/null-pointer-error-when-using-filter</link>
<description>&lt;p&gt;Bumped into this quirk when repling around today: &lt;code&gt;(filter zero? [:hi])&lt;/code&gt; throws a &lt;code&gt; java.lang.ClassCastException&lt;/code&gt; without a proper stack trace.&lt;/p&gt;
&lt;p&gt;I am using Clojure version 1.11.1.1347 .&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13302/null-pointer-error-when-using-filter</guid>
<pubDate>Sat, 16 Sep 2023 07:09:30 +0000</pubDate>
</item>
<item>
<title>Poor Errors when deref'ing a non-IDeref/non-Future</title>
<link>https://ask.clojure.org/index.php/13056/poor-errors-when-derefing-a-non-ideref-non-future</link>
<description>&lt;h2&gt;Problem Statement&lt;/h2&gt;
&lt;p&gt;The function &lt;code&gt;clojure.core/deref&lt;/code&gt; throws a hard-to-decipher &lt;code&gt;ClassCastException&lt;/code&gt; when given an object that's not an instance of &lt;code&gt;clojure.lang.IDeref&lt;/code&gt; or &lt;code&gt;java.util.concurrent.Future&lt;/code&gt;. In my experience on-boarding new Clojure users (at my job and in my open source projects), this comes up and can be quite confusing as it doesn't point to anything obvious in the code. Even with the stack trace, it just points to &lt;code&gt;deref-future&lt;/code&gt;'s definition (instead of a specific line within the function body), which further confuses.&lt;/p&gt;
&lt;h2&gt;Discussion&lt;/h2&gt;
&lt;p&gt;On Slack, I proposed changing the implementation of &lt;code&gt;deref&lt;/code&gt; to be something like &lt;code&gt;(cond (instance? clojure.lang.IDeref ref) ... (instance? java.util.concurrent.Future ref) ... :else (throw (IllegalArgumentException (str ref &quot; cannot be deref'd as it is of type &quot; (class ref) &quot;.&quot;))&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Sean Corfield brought up that such a fix would cost performance for all non-IDeref uses of &lt;code&gt;deref&lt;/code&gt;, which I acknowledged but find acceptable.&lt;/p&gt;
&lt;h2&gt;Repro:&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (def a {})
#'user/a

user=&amp;gt; @a
Execution error (ClassCastException) at user/eval22861 (REPL:0).
class clojure.lang.PersistentArrayMap cannot be cast to class java.util.concurrent.Future (clojure.lang.PersistentArrayMap is in unnamed module of loader 'app'; java.util.concurrent.Future is in module java.base of loader 'bootstrap')

user=&amp;gt; (pst)
ClassCastException class clojure.lang.PersistentArrayMap cannot be cast to class java.util.concurrent.Future (clojure.lang.PersistentArrayMap is in unnamed module of loader 'app'; java.util.concurrent.Future is in module java.base of loader 'bootstrap')
    clojure.core/deref-future (core.clj:2315)
    clojure.core/deref-future (core.clj:2315)
    clojure.core/deref (core.clj:2338)
    clojure.core/deref (core.clj:2323)
    user/eval22863 (NO_SOURCE_FILE:0)
    user/eval22863 (NO_SOURCE_FILE:-1)
    clojure.lang.Compiler.eval (Compiler.java:7194)
    clojure.lang.Compiler.eval (Compiler.java:7149)
    clojure.core/eval (core.clj:3215)
    clojure.core/eval (core.clj:3211)
    clojure.main/repl/read-eval-print--9206/fn--9209 (main.clj:437)
    clojure.main/repl/read-eval-print--9206 (main.clj:437)
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13056/poor-errors-when-derefing-a-non-ideref-non-future</guid>
<pubDate>Mon, 03 Jul 2023 18:08:19 +0000</pubDate>
</item>
<item>
<title>Interest in beginner-friendly variant of (pst)?</title>
<link>https://ask.clojure.org/index.php/13044/interest-in-beginner-friendly-variant-of-pst</link>
<description>&lt;p&gt;Another State of Clojure survey and &quot;error messages&quot; is still the number one priority for improvement.&lt;/p&gt;
&lt;p&gt;A discussion on Slack led to a number of specific pain points for beginners around exceptions and error messages. The one I'd like to focus on here is to provide a beginner-friendly alternative to &lt;code&gt;(pst)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Currently, &lt;code&gt;(pst)&lt;/code&gt; makes a reasonable attempt at demunging names, eliminating &quot;noise&quot;, and shrinking the stack trace some -- but it still leaves a lot to be desired for &lt;em&gt;beginners&lt;/em&gt; who struggle to understand certain exceptions and have difficulty navigating (Java-style) stack traces, especially compared to some other languages that make a big effort to provide user-friendly error messages and stack traces.&lt;/p&gt;
&lt;p&gt;An example from Slack was:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn f [i]
  (fn [j]
    (/ j i)))

(run! #(% 1) (map f (range 3)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The exception printed in the REPL is fine but &lt;code&gt;(pst)&lt;/code&gt; shows:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (pst)
ArithmeticException Divide by zero
        clojure.lang.Numbers.divide (Numbers.java:190)
        user/f/fn--16571 (NO_SOURCE_FILE:3)
        user/eval16576/fn--16577 (NO_SOURCE_FILE:1)
        clojure.core/run!/fn--8906 (core.clj:7849)
...
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The elided part mentions &lt;code&gt;clojure.lang.ArrayChunk.reduce&lt;/code&gt; and then has multiple references to &lt;code&gt;clojure.core.protocols&lt;/code&gt; stuff (and doesn't go deep enough by default to show the original call to &lt;code&gt;clojure.core/run!&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;I think there's an opportunity here for a new &lt;code&gt;clojure.repl/explain&lt;/code&gt; function, taking the same arguments as &lt;code&gt;pst&lt;/code&gt;, that provides both a more detailed explanation of the failure and further reduces the noise in the stack trace that &lt;code&gt;pst&lt;/code&gt; currently displays.&lt;/p&gt;
&lt;p&gt;Ideally, this could be implemented with some basic cleanup in core but with some dynamic hooks that allow other tooling to &quot;install&quot; additional expansion and/or cleanup so that the community can provide libraries and functionality that further improve this aspect of the beginner experience.&lt;/p&gt;
&lt;p&gt;A dynamic hook into &lt;code&gt;ex-str&lt;/code&gt;, for example, would allow community-provided tooling to massage the exception message shown (both for the original REPL input and for both &lt;code&gt;pst&lt;/code&gt; and &lt;code&gt;explain&lt;/code&gt;) so that messages that beginners struggle with, such as &lt;code&gt;class &amp;lt;whatever&amp;gt; cannot be cast to clojure.lang.IFn...&lt;/code&gt; could be rewritten into beginner-friendly language (&lt;code&gt;Expected a function - found a &amp;lt;whatever&amp;gt;&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;Similar dynamic hooks to filter stack frames, and to &quot;print&quot; them to strings, would allow much more friendly output for beginners.&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13044/interest-in-beginner-friendly-variant-of-pst</guid>
<pubDate>Sat, 01 Jul 2023 19:19:33 +0000</pubDate>
</item>
<item>
<title>Vector comparisons raise &quot;clojure.lang.PersistentVector cannot be cast to java.lang.Number&quot; exception</title>
<link>https://ask.clojure.org/index.php/12479/vector-comparisons-clojure-persistentvector-cannot-exception</link>
<description>&lt;p&gt;Hi, when I try to compare certain vectors, I get the above-mentioned error message. I tried in Clojure 1.10.3 and babashka v1.0.168.&lt;br&gt;
These are some of the offending vectors:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(compare [[1] [2 3 4]], [[1] 4])
 ;=&amp;gt; Execution error (ClassCastException) at user/eval1 (REPL:1). 
 ;class java.lang.Long cannot be cast to class clojure.lang.IPersistentVector (java.lang.Long is in module java.base of loader 'bootstrap'; clojure.lang.IPersistentVector is in unnamed module of loader 'app')

(compare [[[1 4 []] [6 2] 6 7 6] [[[10 4]] [10] [[3 5 1 9] 3 1 [7 5] 8] 2] [1 [2 [0 3] [2 10 2] 2] [[2 9 7 8 0] [6 0] 10] 9] [[[8 5 8 3]] 2 [2 3 [7 8]]] [0]]
         [[[[3] 4 4] 10 5 2 []] [7 8] [7 7 [[]]] [] [[[4 10 6 7]] [9] [] 3]])
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Is this a bug, or am I just blind as to why this is &lt;em&gt;obviously&lt;/em&gt; expected behavior?&lt;/p&gt;
&lt;p&gt;I came across this while doing one of the Advent of Code programming exercises yesterday. It asks you to compare a number of vectors, see &lt;a rel=&quot;nofollow&quot; href=&quot;https://adventofcode.com/2022/day/13&quot;&gt;https://adventofcode.com/2022/day/13&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I did solve the exercise by implementing my own vector comparator, according to the specifications given in the exercise. I uploaded the source code in case you want it for testing purposes: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/eNotchy/Advent-of-Code-2022/tree/main/Day13&quot;&gt;https://github.com/eNotchy/Advent-of-Code-2022/tree/main/Day13&lt;/a&gt;&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12479/vector-comparisons-clojure-persistentvector-cannot-exception</guid>
<pubDate>Wed, 14 Dec 2022 21:45:25 +0000</pubDate>
</item>
<item>
<title>Error : ClassCastException</title>
<link>https://ask.clojure.org/index.php/12467/error-classcastexception</link>
<description>&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;I have an error in my console that points to my function :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; (defn sales-by-customer [name-cus]
   (-&amp;gt;&amp;gt; sales_2
       (filter #(= (second %) name-cus))
       (map #(* (Integer/parseInt (last %)) (Double. (products_2 (second %)))))
       (reduce +)
    )
  )
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;sales_2 : [id customers_name products_name quantity]&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;([1 Sara candies 3] 
 [2 Joe jam 3]
 [3 Sara gum 1])
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;products_2 : {products_name price}&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;({candies 6.0} {gum 4.5} {jam 45.1})
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Basically, what I'm trying to do is, when I call (sales-by-customer &quot;Sara&quot;), I want to get the sum of Sara's purchases, which is in this case : (3&lt;em&gt;6.0 + 1&lt;/em&gt;4.5) and display the result.&lt;/p&gt;
&lt;p&gt;When I call my function, I get the following error message :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; Syntax error (ClassCastException) compiling at (db.clj:76:1).
class clojure.lang.LazySeq cannot be cast to class clojure.lang.IFn (clojure.lang.LazySeq and clojure.lang.IFn are in unnamed module of loader 'app')
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Any idea how to solve this error?&lt;br&gt;
I'm supposed to get a number.. I don't know where the cast error occurs...&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12467/error-classcastexception</guid>
<pubDate>Sun, 11 Dec 2022 05:53:56 +0000</pubDate>
</item>
<item>
<title>#object[db$getnameonly 0x66908383 db$getnameonly@66908383] 1</title>
<link>https://ask.clojure.org/index.php/12449/object-dbgetnameonly-0x66908383-dbgetnameonly66908383</link>
<description>&lt;p&gt;Hi!&lt;br&gt;
I've been working on a script and I don't understand what this error means.&lt;/p&gt;
&lt;p&gt;My function, takes a number (id) and extract the first element of a list in my vector. &lt;/p&gt;
&lt;p&gt;Details :&lt;/p&gt;
&lt;p&gt;My function :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; (defn getnameonly [number] 
  (doall (nth (
        (nth 
         (filter #(= number (first %)) customers) 
         0) 
        1) 
       0))
  )
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;where customers is : &lt;br&gt;
(&lt;br&gt;
[1 (John Smith 123 Here Street 456-4567)] &lt;br&gt;
[2 (Sue Jones 43 Rose Court Street 345-7867)] &lt;br&gt;
[3 (Fan Yuhong 165 Happy Lane 345-4533)]&lt;br&gt;
)&lt;/p&gt;
&lt;p&gt;So basically, I want to pull out (return value) &quot;John Smith&quot; if I give 1 to my function.&lt;/p&gt;
&lt;p&gt;The code : &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(nth (
            (nth 
             (filter #(= number (first %)) customers) 
             0) 
            1) 
           0))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;works fine outside the function. However, when I call :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(println getnameonly 1)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I get :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#object[db$getnameonly 0x66908383 db$getnameonly@66908383] 1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Any idea why and how to solve this issue?&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12449/object-dbgetnameonly-0x66908383-dbgetnameonly66908383</guid>
<pubDate>Fri, 09 Dec 2022 06:35:16 +0000</pubDate>
</item>
<item>
<title>problem with intersection</title>
<link>https://ask.clojure.org/index.php/12428/problem-with-intersection</link>
<description>&lt;p&gt;This code works:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(apply clojure.set/intersection [[1 2 2] [1]])
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;but this generates an exception &quot;class clojure.lang.PersistentVector cannot be cast to class clojure.lang.IPersistentSet&quot;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(apply clojure.set/intersection [[\f \o \o] [\o]])
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I don't understand why (I'm new too Clojure, started learning today).&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12428/problem-with-intersection</guid>
<pubDate>Sun, 04 Dec 2022 12:01:18 +0000</pubDate>
</item>
<item>
<title>clojure.stacktrace/print-throwable fails if ex-data is unprintable</title>
<link>https://ask.clojure.org/index.php/12369/clojure-stacktrace-print-throwable-fails-data-unprintable</link>
<description>&lt;p&gt;If an exception is thrown that contains unprintable &lt;code&gt;ex-data&lt;/code&gt;, calling &lt;code&gt;print-stack-trace&lt;/code&gt; will fail because &lt;code&gt;print-throwable&lt;/code&gt; will throw an exception, making it very hard to debug certain failures.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn print-throwable
  &quot;Prints the class and message of a Throwable. Prints the ex-data map
  if present.&quot;
  {:added &quot;1.1&quot;}
  [^Throwable tr]
  (printf &quot;%s: %s&quot; (.getName (class tr)) (.getMessage tr))
  (when-let [info (ex-data tr)]
    (newline)
    (pr info)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Unprintable &lt;code&gt;ex-data&lt;/code&gt; could include a third-party record type that implements multiple interfaces that conflict for &lt;code&gt;print-method&lt;/code&gt; but did not anticipate making the record printable.&lt;/p&gt;
&lt;p&gt;Wrapping that &lt;code&gt;(pr info)&lt;/code&gt; in &lt;code&gt;(try&lt;/code&gt; .. &lt;code&gt;(catch Throwable t&lt;/code&gt; and printing something like &lt;code&gt;(str &quot;&amp;lt;unprintable ex-data: &quot; (ex-message t)&quot;&amp;gt;)&quot;&lt;/code&gt; might be a reasonable compromise here to allow for easier debugging.&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12369/clojure-stacktrace-print-throwable-fails-data-unprintable</guid>
<pubDate>Tue, 08 Nov 2022 23:00:53 +0000</pubDate>
</item>
<item>
<title>Why i get &quot;No suitable driver found for jdbc:://127.0.0.1/&quot; ?</title>
<link>https://ask.clojure.org/index.php/12247/why-i-get-no-suitable-driver-found-for-jdbc-127-0-0-1</link>
<description>&lt;p&gt;Java version :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;openjdk 18.0.2-ea 2022-07-19
OpenJDK Runtime Environment (build 18.0.2-ea+9-Ubuntu-222.04)
OpenJDK 64-Bit Server VM (build 18.0.2-ea+9-Ubuntu-222.04, mixed mode, sharing)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;but when i start the nREPL in my text editor, it's says :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Starting nREPL server...
/usr/lib/jvm/java-11-openjdk-amd64/bin/java ...
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Dependencies :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;:dependencies [[org.clojure/clojure &quot;1.11.1&quot;]
               [com.github.seancorfield/next.jdbc &quot;1.3.834&quot;]
               [org.postgresql/postgresql &quot;42.5.0&quot;]
               [com.layerware/hugsql &quot;0.5.3&quot;]]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;code :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(def db
    {:classname &quot;org.postgresql.Driver&quot;
     :subprotocol &quot;postgresql&quot;
     :subname &quot;reporting&quot;
     :user &quot;admin&quot;
     :password &quot;admin&quot;})

(defn add-user-transaction [users]
  (jdbc/with-transaction [t-conn db]
                         (if-not (find-user t-conn {:id (:id users)})
                           (add-user! t-conn users))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Everything works normal with that configuration, but only when i evaluate&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(add-user-transaction {:id &quot;cheryl&quot;
                   :pass &quot;Cheryl&quot;})
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; the error appears.&lt;/p&gt;
&lt;p&gt;It's asked in &lt;a rel=&quot;nofollow&quot; href=&quot;https://stackoverflow.com/questions/73521391/clojure-execution-error-sqlexception-at-java-sql-drivermanager-getconnection&quot;&gt;Clojure: Execution error (SQLException) at java.sql.DriverManager/getConnection (DriverManager.java:702)&lt;/a&gt; and already have answered, but the only answer in there is using &lt;code&gt;:deps&lt;/code&gt; or &lt;code&gt;deps.edn&lt;/code&gt; (as far i know, this is Maven repository), so how about leiningen? Or did i miss something about leiningen and Maven?&lt;br&gt;
And i even restarting my pc, text editor, and nREPL but nothing change.&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12247/why-i-get-no-suitable-driver-found-for-jdbc-127-0-0-1</guid>
<pubDate>Mon, 26 Sep 2022 21:45:00 +0000</pubDate>
</item>
<item>
<title>Whenever I start a project, an error occurs :main namespace specified in project.clj?</title>
<link>https://ask.clojure.org/index.php/11977/whenever-start-project-occurs-namespace-specified-project</link>
<description>&lt;p&gt;0&lt;/p&gt;
&lt;p&gt;Whichever github project I run I get the same error.&lt;/p&gt;
&lt;p&gt;Now I have started a simple example from the book clojure for brave and true and the same program appears.&lt;/p&gt;
&lt;p&gt;(ns clojure-noob.core (:gen-class))&lt;/p&gt;
&lt;p&gt;(defn -main &quot;I don't do a whole lot ... yet.&quot; [&amp;amp; args] (println &quot;I'm a little teapot!&quot;))&lt;/p&gt;
&lt;p&gt;error is &amp;gt; PS C:\Users\danny\New folder\cftbat-code&amp;gt; lein run &lt;br&gt;
No :main namespace specified in project.clj.&lt;/p&gt;
&lt;p&gt;what can i do and what i am doing wrong?&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11977/whenever-start-project-occurs-namespace-specified-project</guid>
<pubDate>Fri, 17 Jun 2022 14:40:34 +0000</pubDate>
</item>
<item>
<title>Can the &quot;Key must be integer&quot; error message be improved?</title>
<link>https://ask.clojure.org/index.php/11907/can-the-key-must-be-integer-error-message-be-improved</link>
<description>&lt;p&gt;The &lt;code&gt;Key must be integer&lt;/code&gt; error message often catches me off guard and I forget what it meant.&lt;/p&gt;
&lt;p&gt;Could this message be improved so that it is a little more self-describing?&lt;/p&gt;
&lt;p&gt;e.g. &lt;code&gt;Tried to assoc a non-integer key to a vector&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Thanks - V&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11907/can-the-key-must-be-integer-error-message-be-improved</guid>
<pubDate>Wed, 25 May 2022 05:54:04 +0000</pubDate>
</item>
<item>
<title>clojure.data/diff or clojure.set/difference return unexpected results</title>
<link>https://ask.clojure.org/index.php/11889/clojure-data-clojure-difference-return-unexpected-results</link>
<description>&lt;p&gt;Hello folks!, I got a rare issue, where I have a 2 sets of maps and I need get the differences between both like the following example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; first-sequence: #{{:id &quot;test&quot; :status :up} {:id &quot;other&quot; :status :up}}

second-sequence: #{{:id&quot;test&quot; :status :up} {:id &quot;other&quot; :status :up}}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So with these two sets of data I execute the following sentence&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(seq (map #(produce!
            (adapt-schema %) producer)
          (first (clojure.data/diff first-sequence second-sequence))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And I expect as result&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[nil nil #{{:id &quot;test&quot; :status :up} {:id &quot;other&quot; :status :up}]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But I get in tests the following result from de diff and after I publish wrong number of messages&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[#{{:id &quot;test&quot; :status :up} {:id &quot;other&quot; :status :up}#{{:id &quot;test&quot; :status :up} {:id &quot;other&quot; :status :up}nil]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But for example in the REPL I get the correct values so I'm lost with this behavior, any response will be very helpful for me. Thanks!&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11889/clojure-data-clojure-difference-return-unexpected-results</guid>
<pubDate>Thu, 12 May 2022 14:20:12 +0000</pubDate>
</item>
<item>
<title>command works on Linux but fails on Windows</title>
<link>https://ask.clojure.org/index.php/11424/command-works-on-linux-but-fails-on-windows</link>
<description>&lt;p&gt;No question--just providing feedback.  This command works on Linux but fails on Windows:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;clojure -Ttools install io.github.seancorfield/deps-new '{:git/tag &quot;v0.4.8&quot;}' :as new&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Here is the full error report:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;{:clojure.main/message&lt;br&gt;
 &quot;Execution error (ExceptionInfo) at clojure.tools.deps.alpha.extensions.git/coord-err (git.clj:45).\r\nLibrary io.github.seancorfield/deps-new has invalid tag: v0.4.8\r\n&quot;,&lt;br&gt;
 :clojure.main/triage&lt;br&gt;
 {:clojure.error/class clojure.lang.ExceptionInfo,&lt;br&gt;
  :clojure.error/line 45,&lt;br&gt;
  :clojure.error/cause&lt;br&gt;
  &quot;Library io.github.seancorfield/deps-new has invalid tag: v0.4.8&quot;,&lt;br&gt;
  :clojure.error/symbol&lt;br&gt;
  clojure.tools.deps.alpha.extensions.git/coord-err,&lt;br&gt;
  :clojure.error/source &quot;git.clj&quot;,&lt;br&gt;
  :clojure.error/phase :execution},&lt;br&gt;
 :clojure.main/trace&lt;br&gt;
 {:via&lt;br&gt;
  [{:type clojure.lang.ExceptionInfo,&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;:message
&quot;Library io.github.seancorfield/deps-new has invalid tag: v0.4.8&quot;,
:data
{:lib io.github.seancorfield/deps-new,
 :coord
 {:git/tag v0.4.8,
  :git/sha &quot;a059d98edcbe25d5fb5b17052b56ab31a8d4eeff&quot;}},
:at
[clojure.tools.deps.alpha.extensions.git$coord_err
 invokeStatic
 &quot;git.clj&quot;
 45]}],
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;  :trace&lt;br&gt;
  [[clojure.tools.deps.alpha.extensions.git$coord_err&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;invokeStatic
&quot;git.clj&quot;
45]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;   [clojure.tools.deps.alpha.extensions.git$coord_err&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;invoke
&quot;git.clj&quot;
43]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;   [clojure.tools.deps.alpha.extensions.git$eval1234$fn__1236&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;invoke
&quot;git.clj&quot;
66]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;   [clojure.lang.MultiFn invoke &quot;MultiFn.java&quot; 239]&lt;br&gt;
   [clojure.tools.tools.api$install invokeStatic &quot;api.clj&quot; 45]&lt;br&gt;
   [clojure.tools.tools.api$install invoke &quot;api.clj&quot; 20]&lt;br&gt;
   [clojure.lang.AFn applyToHelper &quot;AFn.java&quot; 154]&lt;br&gt;
   [clojure.lang.AFn applyTo &quot;AFn.java&quot; 144]&lt;br&gt;
   [clojure.lang.Var applyTo &quot;Var.java&quot; 705]&lt;br&gt;
   [clojure.core$apply invokeStatic &quot;core.clj&quot; 667]&lt;br&gt;
   [clojure.core$apply invoke &quot;core.clj&quot; 662]&lt;br&gt;
   [clojure.run.exec$exec invokeStatic &quot;exec.clj&quot; 48]&lt;br&gt;
   [clojure.run.exec$exec doInvoke &quot;exec.clj&quot; 39]&lt;br&gt;
   [clojure.lang.RestFn invoke &quot;RestFn.java&quot; 423]&lt;br&gt;
   [clojure.run.exec$_main$fn__205 invoke &quot;exec.clj&quot; 178]&lt;br&gt;
   [clojure.run.exec$_main invokeStatic &quot;exec.clj&quot; 174]&lt;br&gt;
   [clojure.run.exec$_main doInvoke &quot;exec.clj&quot; 139]&lt;br&gt;
   [clojure.lang.RestFn applyTo &quot;RestFn.java&quot; 137]&lt;br&gt;
   [clojure.lang.Var applyTo &quot;Var.java&quot; 705]&lt;br&gt;
   [clojure.core$apply invokeStatic &quot;core.clj&quot; 667]&lt;br&gt;
   [clojure.main$main_opt invokeStatic &quot;main.clj&quot; 514]&lt;br&gt;
   [clojure.main$main_opt invoke &quot;main.clj&quot; 510]&lt;br&gt;
   [clojure.main$main invokeStatic &quot;main.clj&quot; 664]&lt;br&gt;
   [clojure.main$main doInvoke &quot;main.clj&quot; 616]&lt;br&gt;
   [clojure.lang.RestFn applyTo &quot;RestFn.java&quot; 137]&lt;br&gt;
   [clojure.lang.Var applyTo &quot;Var.java&quot; 705]&lt;br&gt;
   [clojure.main main &quot;main.java&quot; 40]],&lt;br&gt;
  :cause&lt;br&gt;
  &quot;Library io.github.seancorfield/deps-new has invalid tag: v0.4.8&quot;,&lt;br&gt;
  :data&lt;br&gt;
  {:lib io.github.seancorfield/deps-new,&lt;br&gt;
   :coord&lt;br&gt;
   {:git/tag v0.4.8,&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;:git/sha &quot;a059d98edcbe25d5fb5b17052b56ab31a8d4eeff&quot;}}}}
&lt;/code&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11424/command-works-on-linux-but-fails-on-windows</guid>
<pubDate>Tue, 28 Dec 2021 18:40:39 +0000</pubDate>
</item>
<item>
<title>Exception in thread &quot;main&quot; java.lang.RuntimeException: Unable to find static field:</title>
<link>https://ask.clojure.org/index.php/11333/exception-thread-main-runtimeexception-unable-static-field</link>
<description>&lt;p&gt;Hey, i`'m still very green in clojure and Java but i want to use this git repo &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/setzer22/alignment_model_text&quot;&gt;https://github.com/setzer22/alignment_model_text&lt;/a&gt; .&lt;/p&gt;
&lt;p&gt;when i execute the Installation script i get the followign error:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; [INFO] --- clojure-maven-plugin:1.8.4:compile (clojure-compile) @ modelvsdocument ---
Compiling edu.upc.modelvsdocument.extraction.common to /home/user/alignment_model_text-master/modelvsdocument/target/classes
WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: clojure.tools.analyzer.utils, being replaced by: #'clojure.tools.analyzer.utils/boolean?
WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: clojure.tools.analyzer, being replaced by: #'clojure.tools.analyzer.utils/boolean?
Exception in thread &quot;main&quot; java.lang.RuntimeException: Unable to find static field: IDENT in class edu.upc.Jfreeling.AnalysisLevel, compiling:(edu/upc/nlp4bpm_commons/Freeling.clj:51:8)
        at clojure.lang.Compiler.analyze(Compiler.java:6720)
        at clojure.lang.Compiler.analyze(Compiler.java:6657)
        at clojure.lang.Compiler$MapExpr.parse(Compiler.java:3072)
        at clojure.lang.Compiler.analyze(Compiler.java:6709)
        at clojure.lang.Compiler.analyze(Compiler.java:6657)
        at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3767)
        at clojure.lang.Compiler.analyzeSeq(Compiler.java:6921)
[...]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So i googled and tried to fix that, but i'm not really sure about the exact problem.&lt;/p&gt;
&lt;p&gt;Does anyone know what causes such an error? And maybe have some tips to solve this?&lt;/p&gt;
&lt;p&gt;Thank you very much!&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11333/exception-thread-main-runtimeexception-unable-static-field</guid>
<pubDate>Tue, 30 Nov 2021 08:45:56 +0000</pubDate>
</item>
<item>
<title>Some CompilerExceptions lack the file path, only having the file name</title>
<link>https://ask.clojure.org/index.php/11248/some-compilerexceptions-lack-file-path-only-having-file-name</link>
<description>&lt;p&gt;Some &lt;code&gt;CompilerException&lt;/code&gt;s, especially ones that are thrown by evaluating the init expression of &lt;code&gt;def&lt;/code&gt; forms, only contain the file name, not the file path.&lt;/p&gt;
&lt;p&gt;For example, let's say you have a file that looks like:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns example.core1)

(def x (throw (ex-info &quot;error!!&quot; {})))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And load the namespace, then you'll see the &lt;code&gt;CompilerException&lt;/code&gt; only contains the file name, instead of the file path:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (require 'example.core1)
Execution error (ExceptionInfo) at example.core1/fn (core1.clj:3).
error!!
user=&amp;gt; (ex-data *e)
#:clojure.error{:phase :execution, :line 3, :column 8, :source &quot;core1.clj&quot;}
user=&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is in contrast to other &lt;code&gt;CompilerException&lt;/code&gt;s, which do contain the file path in their ex-data. For example, let's say you have another file that looks like:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns example.core2)

(no-such-function)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And then:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (require 'example.core2)
Syntax error compiling at (example/core2.clj:3:1).
Unable to resolve symbol: no-such-function in this context
user=&amp;gt; (ex-data *e)
#:clojure.error{:phase :compile-syntax-check, :line 3, :column 1, :source &quot;example/core2.clj&quot;}
user=&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It seems that this difference comes from the fact that a &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/blob/b8132f92f3c3862aa6cdd8a72e4e74802a63f673/src/jvm/clojure/lang/Compiler.java?_pjax=%23js-repo-pjax-container%2C%20div%5Bitemtype%3D%22http%3A%2F%2Fschema.org%2FSoftwareSourceCode%22%5D%20main%2C%20%5Bdata-pjax-container%5D#L595&quot;&gt;&lt;code&gt;DefExpr&lt;/code&gt; is constructed with &lt;code&gt;SOURCE&lt;/code&gt;&lt;/a&gt; passed, instead of &lt;code&gt;SOURCE_PATH&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;It would be nice if &lt;code&gt;CompilerException&lt;/code&gt;s always contain the file path (as far as possible), since it may be hard to identify the exact location where the exception occurred from only the file name.&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11248/some-compilerexceptions-lack-file-path-only-having-file-name</guid>
<pubDate>Thu, 04 Nov 2021 15:32:06 +0000</pubDate>
</item>
<item>
<title>Improve error messages from `reify` forms</title>
<link>https://ask.clojure.org/index.php/11142/improve-error-messages-from-reify-forms</link>
<description>&lt;p&gt;I had a syntax error in a &lt;code&gt;reify&lt;/code&gt; form today and the error was pretty cryptic:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defprotocol Foo
  (foo [a]))

(reify Foo
  (foo a
    (inc a)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Produces the following error:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Syntax error (IllegalArgumentException) compiling at (REPL:1:1).&lt;br&gt;
Don't know how to create ISeq from: clojure.lang.Symbol&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It would be beneficial if the error message contained the word &lt;code&gt;reify&lt;/code&gt; and &lt;code&gt;foo&lt;/code&gt; as breadcrumbs, that would have lead me to identify the error more easily.&lt;/p&gt;
&lt;p&gt;Also the line number of a column are incorrect - they refer to the position of the opening paren of the reify form (line 1, column 1) whereas my error is on line 2, column 7.&lt;/p&gt;
&lt;p&gt;Thinking about a better message, something like:&lt;/p&gt;
&lt;p&gt; &amp;gt; Syntax error in &lt;code&gt;reify&lt;/code&gt; form – found symbol 'a' when expecting an argument list.&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11142/improve-error-messages-from-reify-forms</guid>
<pubDate>Thu, 07 Oct 2021 12:54:12 +0000</pubDate>
</item>
<item>
<title>Literal set with duplicate values reports error with wrong line number</title>
<link>https://ask.clojure.org/index.php/10513/literal-with-duplicate-values-reports-error-with-wrong-number</link>
<description>&lt;p&gt;Repro:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;% cat src/dupes.clj
(ns dupes
  (:gen-class))

(defn -main
  []
  (let [x 1 y 1]
    (pr-str &quot;this is not the error you're looking for&quot;)
    ;; This is a lengthy, multi-line comment. It serves no other purpose than to put
    ;; distance between the last line to emit a line number and the line that throws the
    ;; exception
    #{x y}))

% clj -M -m dupes
Execution error (IllegalArgumentException) at dupes/-main (dupes.clj:7).
Duplicate key: 1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Reports error at line 7, but should be line 11.&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10513/literal-with-duplicate-values-reports-error-with-wrong-number</guid>
<pubDate>Thu, 22 Apr 2021 18:04:25 +0000</pubDate>
</item>
<item>
<title>Stacktraces with clojure functions contain irrelevant information</title>
<link>https://ask.clojure.org/index.php/10470/stacktraces-clojure-functions-contain-irrelevant-information</link>
<description>&lt;h3&gt;Background&lt;/h3&gt;
&lt;p&gt;I saw &lt;a rel=&quot;nofollow&quot; href=&quot;https://www.reddit.com/r/Clojure/comments/mldk16/state_of_clojure_2021_results/gtlyviz/&quot;&gt;reddit discussion&lt;/a&gt; about error messages and one user's comment about signal-to-noise ratio resonated with me and got me thinking about how stack traces are presented to the user at the REPL.&lt;/p&gt;
&lt;h3&gt;Context&lt;/h3&gt;
&lt;p&gt;I had a look at various developments in this area, including:&lt;br&gt;
- &lt;a rel=&quot;nofollow&quot; href=&quot;https://twitter.com/stuarthalloway/status/1148295437448876032&quot;&gt;Stuart Holloway's opinion&lt;/a&gt; that stack traces are always the right length&lt;br&gt;
- &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/mmcgrana/clj-stacktrace&quot;&gt;clj-stacktrace&lt;/a&gt; library&lt;br&gt;
- &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/AvisoNovate/pretty&quot;&gt;pretty&lt;/a&gt; library&lt;br&gt;
- &lt;a rel=&quot;nofollow&quot; href=&quot;https://archive.clojure.org/design-wiki/display/design/Stacktraces.html&quot;&gt;clojure archive&lt;/a&gt; page with design iterations around stack traces, including &lt;a rel=&quot;nofollow&quot; href=&quot;https://gist.github.com/mmcgrana/649282&quot;&gt;this snippet&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;My thoughts on this is that existing libraries are either try to hide too much (pretty) or mostly concerned with presentation/formatting and not the actual contents (clj-stacktrace). I generally agree with Stuart that stack traces are the right length because every stack element is truth, an unambiguous description of the stack of methods that were executing when exception happened.&lt;/p&gt;
&lt;h3&gt;Scope&lt;/h3&gt;
&lt;p&gt;This discussion is about stack traces presented to programmer at the REPL, think &lt;code&gt;Throwable-&amp;gt;map&lt;/code&gt; and &lt;code&gt;clojure.core/print-throwable&lt;/code&gt;, not re-wrapping all thrown exceptions.&lt;/p&gt;
&lt;h3&gt;Problem&lt;/h3&gt;
&lt;p&gt;The purpose of stack trace is to present useful information about executed methods that give context to exception. I think that one aspect that makes this information useful is ability to see/navigate to code that led to an exception. In case of functions defined in Clojure code, there are no methods/enclosing classes to see/navigate to since bytecode for those is emitted dynamically from function definitions. In addition to that, stack traces of what semantically is a single function call usually contain multiple elements where some of those elements point to a line where the function is defined, which is also not useful.&lt;/p&gt;
&lt;h3&gt;Illustration&lt;/h3&gt;
&lt;p&gt;Given a file &lt;code&gt;repro.clj&lt;/code&gt; (I included line numbers):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1 (defn foo []
2   (/ 1 0))
3 
4 (defn bar []
5   (foo))
6 
7 (bar)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Loading this file in the REPL and showing the error will show the following stack trace:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;clj
Clojure 1.10.1
user=&amp;gt; (load-file &quot;repro.clj&quot;)
Syntax error (ArithmeticException) compiling at (C:\Users\Vlaaad\Projects\vlaaad.github.io\repro.clj:7:1).
Divide by zero
user=&amp;gt; *e
#error {
 :cause &quot;Divide by zero&quot;
 :via
 [{:type clojure.lang.Compiler$CompilerException
   :message &quot;Syntax error compiling at (C:\\Users\\Vlaaad\\Projects\\vlaaad.github.io\\repro.clj:7:1).&quot;
   :data #:clojure.error{:phase :compile-syntax-check, :line 7, :column 1, :source &quot;C:\\Users\\Vlaaad\\Projects\\vlaaad.github.io\\repro.clj&quot;}
   :at [clojure.lang.Compiler load &quot;Compiler.java&quot; 7648]}
  {:type java.lang.ArithmeticException
   :message &quot;Divide by zero&quot;
   :at [clojure.lang.Numbers divide &quot;Numbers.java&quot; 188]}]
 :trace
 [[clojure.lang.Numbers divide &quot;Numbers.java&quot; 188]
  [clojure.lang.Numbers divide &quot;Numbers.java&quot; 3901]
  [user$foo invokeStatic &quot;repro.clj&quot; 2]
  [user$foo invoke &quot;repro.clj&quot; 1]
  [user$bar invokeStatic &quot;repro.clj&quot; 5]
  [user$bar invoke &quot;repro.clj&quot; 4]
  [user$eval140 invokeStatic &quot;repro.clj&quot; 7]
  [user$eval140 invoke &quot;repro.clj&quot; 7]
  [clojure.lang.Compiler eval &quot;Compiler.java&quot; 7177]
  [clojure.lang.Compiler load &quot;Compiler.java&quot; 7636]
  [clojure.lang.Compiler loadFile &quot;Compiler.java&quot; 7574]
  [clojure.lang.RT$3 invoke &quot;RT.java&quot; 327]
  [user$eval1 invokeStatic &quot;NO_SOURCE_FILE&quot; 1]
  [user$eval1 invoke &quot;NO_SOURCE_FILE&quot; 1]
  [clojure.lang.Compiler eval &quot;Compiler.java&quot; 7177]
  [clojure.lang.Compiler eval &quot;Compiler.java&quot; 7132]
  [clojure.core$eval invokeStatic &quot;core.clj&quot; 3214]
  [clojure.core$eval invoke &quot;core.clj&quot; 3210]
  [clojure.main$repl$read_eval_print__9086$fn__9089 invoke &quot;main.clj&quot; 437]
  [clojure.main$repl$read_eval_print__9086 invoke &quot;main.clj&quot; 437]
  [clojure.main$repl$fn__9095 invoke &quot;main.clj&quot; 458]
  [clojure.main$repl invokeStatic &quot;main.clj&quot; 458]
  [clojure.main$repl_opt invokeStatic &quot;main.clj&quot; 522]
  [clojure.main$main invokeStatic &quot;main.clj&quot; 667]
  [clojure.main$main doInvoke &quot;main.clj&quot; 616]
  [clojure.lang.RestFn invoke &quot;RestFn.java&quot; 397]
  [clojure.lang.AFn applyToHelper &quot;AFn.java&quot; 152]
  [clojure.lang.RestFn applyTo &quot;RestFn.java&quot; 132]
  [clojure.lang.Var applyTo &quot;Var.java&quot; 705]
  [clojure.main main &quot;main.java&quot; 40]]}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let's focus on the stack trace elements that belong to &lt;code&gt;repro.clj&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[clojure.lang.Numbers divide &quot;Numbers.java&quot; 188]
[clojure.lang.Numbers divide &quot;Numbers.java&quot; 3901]
[user$foo invokeStatic &quot;repro.clj&quot; 2]
[user$foo invoke &quot;repro.clj&quot; 1]
[user$bar invokeStatic &quot;repro.clj&quot; 5]
[user$bar invoke &quot;repro.clj&quot; 4]
[user$eval140 invokeStatic &quot;repro.clj&quot; 7]
[user$eval140 invoke &quot;repro.clj&quot; 7]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Every Clojure function call in code has 2 corresponding stack elements: &lt;code&gt;invoke&lt;/code&gt; and &lt;code&gt;invokeStatic&lt;/code&gt;. Method &lt;code&gt;invoke&lt;/code&gt; for classes &lt;code&gt;user$foo&lt;/code&gt; and &lt;code&gt;user$bar&lt;/code&gt; point to lines 1 and 4. If you look at the &lt;code&gt;repro.clj&lt;/code&gt;, you'll notice these are the lines where function &lt;code&gt;foo&lt;/code&gt; and &lt;code&gt;bar&lt;/code&gt; are defined — this information is not useful, and generally stack traces for java code don't point to lines where methods are defined, only to lines inside the method bodies that invoke methods higher on the stack. While it is possible to use interop to call &lt;code&gt;.invoke&lt;/code&gt; directly as this is defined in IFn, &lt;code&gt;invokeStatic&lt;/code&gt; is a method emitted by the compiler and arguably is an implementation detail.&lt;/p&gt;
&lt;h3&gt;Possible solutions?&lt;/h3&gt;
&lt;h4&gt;Do nothing&lt;/h4&gt;
&lt;p&gt;Stuart might be right — if I am debugging bytecode-related issue, I would certainly be interested in these details. Also, some future version of Clojure might emit function bytecode differently, leading to a fewer amount of more readable stack traces. &lt;/p&gt;
&lt;h4&gt;Merge stack elements&lt;/h4&gt;
&lt;p&gt;This approach merges stack elements of a same function that keeps only public &lt;code&gt;invoke&lt;/code&gt; methods visible and reports lines that actually did the call to next method in the stack. This is a pretty minimal filtering that will make stacktrace for the repro exception look like that:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[clojure.lang.Numbers divide &quot;Numbers.java&quot; 188]
[clojure.lang.Numbers divide &quot;Numbers.java&quot; 3901]
[user$foo invoke &quot;repro.clj&quot; 2]
[user$bar invoke &quot;repro.clj&quot; 5]
[user$eval140 invoke &quot;repro.clj&quot; 7]
[clojure.lang.Compiler eval &quot;Compiler.java&quot; 7177]
[clojure.lang.Compiler load &quot;Compiler.java&quot; 7636]
[clojure.lang.Compiler loadFile &quot;Compiler.java&quot; 7574]
[clojure.lang.RT$3 invoke &quot;RT.java&quot; 327]
[user$eval1 invoke &quot;NO_SOURCE_FILE&quot; 1]
[clojure.lang.Compiler eval &quot;Compiler.java&quot; 7177]
[clojure.lang.Compiler eval &quot;Compiler.java&quot; 7132]
[clojure.core$eval invoke &quot;core.clj&quot; 3214]
[clojure.main$repl$read_eval_print__9086$fn__9089 invoke &quot;main.clj&quot; 437]
[clojure.main$repl$fn__9095 invoke &quot;main.clj&quot; 458]
[clojure.main$repl invoke &quot;main.clj&quot; 458]
[clojure.main$repl_opt invoke &quot;main.clj&quot; 522]
[clojure.main$main invoke &quot;main.clj&quot; 667]
[clojure.lang.RestFn invoke &quot;RestFn.java&quot; 397]
[clojure.lang.AFn applyToHelper &quot;AFn.java&quot; 152]
[clojure.lang.RestFn applyTo &quot;RestFn.java&quot; 132]
[clojure.lang.Var applyTo &quot;Var.java&quot; 705]
[clojure.main main &quot;main.java&quot; 40]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I think this already does a decent job at reducing signal-to-noise ratio, and if you debug bytecode-related issues, you can still get the full stack trace using &lt;code&gt;.getStackTrace&lt;/code&gt; on an exception object.&lt;/p&gt;
&lt;h4&gt;Make Clojure stack elements resemble code&lt;/h4&gt;
&lt;p&gt;A part of Clojure philosophy is to prefer functions over methods, perhaps stack elements pointing to Clojure functions should look like functions and not methods? Most of the time there is no &lt;code&gt;.invoke&lt;/code&gt; interop in code. I would prefer to act upon &lt;code&gt;user/foo&lt;/code&gt;, not &lt;code&gt;user$foo invoke&lt;/code&gt;, because this is something I can actually see in my code. One might argue that even stack elements like &lt;code&gt;clojure.lang.AFn applyToHelper&lt;/code&gt; and &lt;code&gt;clojure.lang.RestFn invoke&lt;/code&gt; are also unnecessary since they are implementation details that make any Clojure functions invokable with variadic arguments (there is &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/blob/3c9307e27479d450e3f1cdf7903458b83ebf52d7/src/clj/clojure/core.clj#L5874&quot;&gt;some filtering&lt;/a&gt; of those details already!). There are many unknowns in this direction that I didn't try to answer because I'm not sure if it's worth pursuing, but here is an illustration of how stack traces might look in that case:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[clojure.lang.Numbers.divide &quot;Numbers.java&quot; 188]
[clojure.lang.Numbers.divide &quot;Numbers.java&quot; 3901]
[user/foo &quot;repro.clj&quot; 2]
[user/bar &quot;repro.clj&quot; 5]
[user/eval140 &quot;repro.clj&quot; 7]
[clojure.lang.Compiler.eval &quot;Compiler.java&quot; 7177]
[clojure.lang.Compiler.load &quot;Compiler.java&quot; 7636]
[clojure.lang.Compiler.loadFile &quot;Compiler.java&quot; 7574]
[clojure.lang.RT$3.invoke &quot;RT.java&quot; 327]
[user/eval1 &quot;NO_SOURCE_FILE&quot; 1]
[clojure.lang.Compiler.eval &quot;Compiler.java&quot; 7177]
[clojure.lang.Compiler.eval &quot;Compiler.java&quot; 7132]
[clojure.core/eval &quot;core.clj&quot; 3214]
[clojure.main/repl/read-eval-print--9086/fn--9089 &quot;main.clj&quot; 437]
[clojure.main/repl/fn--9095 &quot;main.clj&quot; 458]
[clojure.main/repl &quot;main.clj&quot; 458]
[clojure.main/repl-opt &quot;main.clj&quot; 522]
[clojure.main/main &quot;main.clj&quot; 667]
[clojure.main.main &quot;main.java&quot; 40]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Some open questions:&lt;br&gt;
- representing Clojure function calls as single symbol instead of a pair class+method asks to represent java method calls as single symbols, how should those look like? &lt;code&gt;clojure.lang.Compiler/eval&lt;/code&gt; vs &lt;code&gt;clojure.lang.Compiler.eval&lt;/code&gt; vs something else?&lt;br&gt;
- how to show method calls for deftypes/reifies? those are both Clojure and methods...&lt;br&gt;
- are Var/AFn/RestFn stack elements truly irrelevant?&lt;/p&gt;
&lt;h4&gt;Something else&lt;/h4&gt;
&lt;p&gt;There might be other options...&lt;/p&gt;
&lt;p&gt;What do you think?&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10470/stacktraces-clojure-functions-contain-irrelevant-information</guid>
<pubDate>Mon, 12 Apr 2021 20:20:58 +0000</pubDate>
</item>
<item>
<title>Support for suppressed exceptions</title>
<link>https://ask.clojure.org/index.php/10384/support-for-suppressed-exceptions</link>
<description>&lt;p&gt;Java 7 try-with-resources makes sure no exceptions are lost in case &lt;code&gt;close&lt;/code&gt; throws while another exception is already bubbling from the block's body. This is done by attaching the latter exception to the former as suppressed. Suppressed exceptions are made visible in &lt;code&gt;printStackTrace&lt;/code&gt; making it easier to diagnose complex problems involving multiple failures.&lt;/p&gt;
&lt;p&gt;It seems &lt;code&gt;with-open&lt;/code&gt; doesn't record suppressed exceptions. &lt;code&gt;close&lt;/code&gt;-ing is handled in the &lt;code&gt;finally&lt;/code&gt; block, and if the stack has been already unwinding any exceptions thrown by &lt;code&gt;close&lt;/code&gt; will override.&lt;/p&gt;
&lt;p&gt;On top of that, &lt;code&gt;clojure.stacktrace&lt;/code&gt; seems to ignore the existence of suppressed exceptions entirely.&lt;/p&gt;
&lt;p&gt;Is there a reason not to support suppressed exceptions? Or is this just a legacy of pre-Java-7 implementation? Would you consider adding the support in?&lt;/p&gt;
&lt;p&gt;Here's one implementation of &lt;code&gt;with-open&lt;/code&gt; supporting suppression: &lt;a rel=&quot;nofollow&quot; href=&quot;https://gist.github.com/mszajna/0ccbdfbd10927ff5d9517aaeb319952a&quot;&gt;https://gist.github.com/mszajna/0ccbdfbd10927ff5d9517aaeb319952a&lt;/a&gt;&lt;br&gt;
It forgoes of the finally block, closing the resource outside the try block in the happy case. In the unhappy case, the catch block does the suppression recording and makes sure the original exception propagates up.&lt;/p&gt;
&lt;p&gt;I can imagine another implementation could make use of piece of state to record original exception and keep the finally block perhaps.&lt;/p&gt;
&lt;p&gt;I don't have a proposal for &lt;code&gt;clojure.stacktrace&lt;/code&gt; at this stage. I'm not sure whether this should be a new function or should the suppressed exceptions be included in &lt;code&gt;print-cause-trace&lt;/code&gt;. On one hand, backward compatibility is nice, on the other, it would be great for existing tooling to take advantage of this improvement.&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10384/support-for-suppressed-exceptions</guid>
<pubDate>Tue, 30 Mar 2021 12:08:05 +0000</pubDate>
</item>
<item>
<title>signal an error on mulimethod without a dispatch function?</title>
<link>https://ask.clojure.org/index.php/9737/signal-an-error-on-mulimethod-without-a-dispatch-function</link>
<description>&lt;pre&gt;&lt;code&gt;user=&amp;gt; (defmulti thing)
#'user/thing
user=&amp;gt; (defmethod thing :default [x] :hi)
#object[clojure.lang.MultiFn 0x7b60c3e &quot;clojure.lang.MultiFn@7b60c3e&quot;]
user=&amp;gt; (thing :hello)
Execution error (NullPointerException) at user/eval144 (REPL:1).
null
user=&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Someone was surprised by this behavior and missed the error that there was no dispatch function defined. Notable that there is some validation for &lt;code&gt;defmulti&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; (defmulti thing [x] (fn [x] x))
Syntax error macroexpanding defmulti at (REPL:1:1).
The syntax for defmulti has changed. Example: (defmulti name dispatch-fn :default dispatch-value)
user=&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9737/signal-an-error-on-mulimethod-without-a-dispatch-function</guid>
<pubDate>Wed, 28 Oct 2020 20:09:35 +0000</pubDate>
</item>
<item>
<title>case has incorrect + difficult-to-comprehend behavior matching 'quote on Clojure 1.10.0</title>
<link>https://ask.clojure.org/index.php/9508/incorrect-difficult-comprehend-behavior-matching-clojure</link>
<description>&lt;p&gt;I'm implementing a small Lisp interpreter, which led me to discover this bug in the implementation of &lt;code&gt;case&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(case &quot;s&quot;
  'quote &quot;quote&quot;
  &quot;default&quot;)

;; Syntax error macroexpanding case at (org:localhost:56082(clj)*:131:16).
;; Duplicate case test constant: quote
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I thought this might be a good workaround:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(case 'quote
  (symbol &quot;quote&quot;) &quot;quote&quot;
  &quot;default&quot;)
;; =&amp;gt; &quot;default&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This doesn't work, it returns &quot;default&quot;.&lt;/p&gt;
&lt;p&gt;Strangely, even though &lt;code&gt;(symbol quote)&lt;/code&gt; would be invalid, since &lt;code&gt;quote&lt;/code&gt; is not bound, THIS does &quot;work&quot; by returning &lt;code&gt;&quot;quote&quot;&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(case 'quote
  (symbol quote) &quot;quote&quot;
  &quot;default&quot;)
;; =&amp;gt; &quot;quote&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Very weird. And look at this. Let's try a case of &lt;code&gt;'face&lt;/code&gt;. What will it return?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(case 'quote
  'face &quot;face&quot;
  &quot;default&quot;)
;; =&amp;gt; &quot;face&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It matches &lt;code&gt;'quote&lt;/code&gt;!&lt;/p&gt;
&lt;p&gt;Actually anything quoted matches:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(case 'quote
  (quote 123) &quot;123&quot;
  &quot;default&quot;)
;; =&amp;gt; &quot;123&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; Hopefully this will be enough for this to make sense to someone with knowledge of &lt;code&gt;case&lt;/code&gt;'s macroexpansion.&lt;/p&gt;
&lt;p&gt;Cheers!&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9508/incorrect-difficult-comprehend-behavior-matching-clojure</guid>
<pubDate>Sun, 26 Jul 2020 21:18:09 +0000</pubDate>
</item>
<item>
<title>Calling deref on &quot;clojure.core/*clojure-version*&quot; yields &quot;Unbound: #'clojure.core/*clojure-version*&quot;</title>
<link>https://ask.clojure.org/index.php/9404/calling-clojure-clojure-version-unbound-clojure-clojure</link>
<description>&lt;p&gt;I was trying to use a library that calls requiring-resolve (which any attempt to call would throw an IllegalStateException). While trying to find the issue, I found that when I call &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;System.out.println(Clojure.var(&quot;clojure.core/deref&quot;).invoke(Clojure.var(&quot;clojure.core/*clojure-version*&quot;)));
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I get &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Unbound: #'clojure.core/*clojure-version*
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Is there some way to fix this?&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9404/calling-clojure-clojure-version-unbound-clojure-clojure</guid>
<pubDate>Tue, 23 Jun 2020 21:13:59 +0000</pubDate>
</item>
<item>
<title>Improve error messages for clojure.core/case</title>
<link>https://ask.clojure.org/index.php/9152/improve-error-messages-for-clojure-core-case</link>
<description>&lt;p&gt;The error message generated when &lt;code&gt;case&lt;/code&gt; encounters a non-matching clause uses &lt;code&gt;str&lt;/code&gt;, resulting in &lt;code&gt;nil&lt;/code&gt; being rendered as an empty string, and strings without quote marks. &lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(let [x nil]
  (case x
    1 :a 2 :b))
;; =&amp;gt;
;; Unhandled java.lang.IllegalArgumentException
;; No matching clause for x:
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And the potentially confusing &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(let [x &quot;1&quot;]
  (case x
    1 :a 2 :b))
;; =&amp;gt;
;; Unhandled java.lang.IllegalArgumentException
;; No matching clause for x: 1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Would it be less ambiguous to use &lt;code&gt;pr-str&lt;/code&gt; for the value resulting in &lt;code&gt;nil&lt;/code&gt; and &lt;code&gt;&quot;1&quot;&lt;/code&gt; respectively? &lt;/p&gt;
&lt;p&gt;Note: a similar issue was raised for Clojurescript here:&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;https://ask.clojure.org/index.php/6575/improve-error-messages-using-instead-when-printing-objects&quot;&gt;https://ask.clojure.org/index.php/6575/improve-error-messages-using-instead-when-printing-objects&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Logged: &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJ-2564&quot;&gt;https://clojure.atlassian.net/browse/CLJ-2564&lt;/a&gt;&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9152/improve-error-messages-for-clojure-core-case</guid>
<pubDate>Fri, 13 Mar 2020 04:44:30 +0000</pubDate>
</item>
<item>
<title>Namespace.java: addAlias exception could be more informative</title>
<link>https://ask.clojure.org/index.php/8705/namespace-java-addalias-exception-could-more-informative</link>
<description>&lt;p&gt;In &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/blob/653b8465845a78ef7543e0a250078eea2d56b659/src/jvm/clojure/lang/Namespace.java#L224-L225&quot;&gt;https://github.com/clojure/clojure/blob/653b8465845a78ef7543e0a250078eea2d56b659/src/jvm/clojure/lang/Namespace.java#L224-L225&lt;/a&gt;, the &lt;code&gt;ns&lt;/code&gt; argument is not included in the exception message.&lt;/p&gt;
&lt;p&gt;This hinders debuggabiliity, especially when the &lt;code&gt;.addAlias&lt;/code&gt; call didn't originate from intentful aliasing, but rather, as a result of re-evaluating a namespace (which is the AST-building strategy that tools such as &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/jonase/eastwood&quot;&gt;https://github.com/jonase/eastwood&lt;/a&gt; use).&lt;/p&gt;
&lt;p&gt;Have you considered improving the message?&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8705/namespace-java-addalias-exception-could-more-informative</guid>
<pubDate>Thu, 10 Oct 2019 15:55:01 +0000</pubDate>
</item>
<item>
<title>How to display better errors in clojure stacktraces? is this planned to be attacked on a new clojure version?</title>
<link>https://ask.clojure.org/index.php/8343/display-clojure-stacktraces-planned-attacked-clojure-version</link>
<description>&lt;p&gt;Clojure stacktraces are pretty cryptic and hard to follow, is there a library to display better errors or format the stacktraces?&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8343/display-clojure-stacktraces-planned-attacked-clojure-version</guid>
<pubDate>Tue, 06 Aug 2019 14:09:25 +0000</pubDate>
</item>
<item>
<title>ex-str can be misleading when handling s/explain-data</title>
<link>https://ask.clojure.org/index.php/8313/ex-str-can-be-misleading-when-handling-s-explain-data</link>
<description>&lt;p&gt;I'm using &lt;code&gt;s/explain-data&lt;/code&gt; within &lt;code&gt;if-let&lt;/code&gt; to decide in one pass whether some data is valid or whether I should throw an exception:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;(if-let [explanation (s/explain-data spec x)]&lt;/code&gt;&lt;br&gt;
&lt;code&gt;  (throw (ex-info &quot;Invalid&quot; explanation))&lt;/code&gt;&lt;br&gt;
&lt;code&gt;  x)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;When handled by my Cursive repl, this is &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/blob/38524061dcb14c598c239be87184b3378ffc5bac/src/clj/clojure/main.clj#L328&quot;&gt;rendered as&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;Execution error - invalid arguments to name.space/function-name at (source.clj:nn)&lt;/code&gt;&lt;br&gt;
...then the explain-str form of the error&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;My problem is that the message is misleading—there could be reasons other than &quot;invalid arguments&quot; that the data were invalid! Wouldn't it be better if the text was simply:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;Execution error - data validation failed within name.space/function-name at (source.clj:nn)&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8313/ex-str-can-be-misleading-when-handling-s-explain-data</guid>
<pubDate>Fri, 02 Aug 2019 15:19:51 +0000</pubDate>
</item>
<item>
<title>How do I get a full stack trace instead of &quot;... 12 more&quot;?</title>
<link>https://ask.clojure.org/index.php/8207/how-do-i-get-a-full-stack-trace-instead-of-12-more</link>
<description>&lt;p&gt;Using &lt;code&gt;lein run&lt;/code&gt;. There are no references to my *.clj file anywhere, so I don't know where this &lt;code&gt;java.lang.NullPointerException&lt;/code&gt; is coming from??&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Exception in thread &quot;main&quot; Syntax error compiling at (/tmp/form-init542794133375754487.clj:1:72).
    at clojure.lang.Compiler.load(Compiler.java:7647)
    at clojure.lang.Compiler.loadFile(Compiler.java:7573)
    at clojure.main$load_script.invokeStatic(main.clj:452)
    at clojure.main$init_opt.invokeStatic(main.clj:454)
    at clojure.main$init_opt.invoke(main.clj:454)
    at clojure.main$initialize.invokeStatic(main.clj:485)
    at clojure.main$null_opt.invokeStatic(main.clj:519)
    at clojure.main$null_opt.invoke(main.clj:516)
    at clojure.main$main.invokeStatic(main.clj:598)
    at clojure.main$main.doInvoke(main.clj:561)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.lang.Var.applyTo(Var.java:705)
    at clojure.main.main(main.java:37)
Caused by: java.lang.NullPointerException
    at xinova.model$reload_dbs.invokeStatic(model.clj:78)
    at xinova.model$reload_dbs.invoke(model.clj:78)
    at xinova.core$_main.invokeStatic(core.clj:18)
    at xinova.core$_main.doInvoke(core.clj:14)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.lang.Var.invoke(Var.java:384)
    at user$eval140.invokeStatic(form-init542794133375754487.clj:1)
    at user$eval140.invoke(form-init542794133375754487.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:7176)
    at clojure.lang.Compiler.eval(Compiler.java:7166)
    at clojure.lang.Compiler.load(Compiler.java:7635)
    ... 12 more
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8207/how-do-i-get-a-full-stack-trace-instead-of-12-more</guid>
<pubDate>Fri, 26 Jul 2019 19:10:03 +0000</pubDate>
</item>
<item>
<title>Provide guidance on configuring error printer for handling errors</title>
<link>https://ask.clojure.org/index.php/3785/provide-guidance-configuring-error-printer-handling-errors</link>
<description>As of Clojure 1.10.1-beta1, errors in non-REPL environments are handled with `ex-str`, which is nice because `ex-str` in turn calls `*explain-out*` which is user-configurable. &lt;br /&gt;
&lt;br /&gt;
However, there is not clear guidance on how best to configure `s/*explain-out*` such that this configuration will be run before other namespaces are loaded. Perhaps 'user.clj' is the correct place for this, but will that always be loaded for all non-REPL tasks?&lt;br /&gt;
&lt;br /&gt;
For instance, this code would set up Expound, but right now I'm not sure how to reliably run it before other namespaces load:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(require '[expound.alpha :as expound] '[clojure.spec.alpha :as s])&lt;br /&gt;
(alter-var-root #'s/*explain-out* (constantly (expound/custom-printer {:print-specs? false :show-valid-values? true :theme :figwheel-theme})))&lt;br /&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/3785/provide-guidance-configuring-error-printer-handling-errors</guid>
<pubDate>Wed, 03 Apr 2019 01:48:27 +0000</pubDate>
</item>
<item>
<title>Use &quot;constructor&quot; instead of &quot;ctor&quot; in Compiler error messages</title>
<link>https://ask.clojure.org/index.php/1922/use-constructor-instead-of-ctor-in-compiler-error-messages</link>
<description>&lt;p&gt;In this example:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;user=&amp;gt; (java.net.URL. #_&quot;missing arg&quot;)
Syntax error (IllegalArgumentException) compiling new at (REPL:1:1).
No matching ctor found for class java.net.URL&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;the use of &quot;ctor&quot; is confusing. It matches the code variable name, but the user isn't looking at that.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Patch:&lt;/strong&gt; CLJ-2445.patch - replace &quot;ctor&quot; with &quot;constructor&quot; in error messages.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Prescreened by:&lt;/strong&gt; Alex Miller&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/1922/use-constructor-instead-of-ctor-in-compiler-error-messages</guid>
<pubDate>Mon, 26 Nov 2018 13:57:54 +0000</pubDate>
</item>
<item>
<title>Separate compiler exceptions into :compilation and :compile-syntax-check</title>
<link>https://ask.clojure.org/index.php/4249/separate-compiler-exceptions-compilation-compile-syntax</link>
<description>With the new error reporting phases in Clojure 1.10, we identified two separate phases - :compile-syntax-check (for syntax errors found by compiler) and :compilation for errors that occur during compilation but that are not syntax errors. &lt;br /&gt;
&lt;br /&gt;
Example of the latter:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
user=&amp;gt; a/b&lt;br /&gt;
Syntax error compiling at (REPL:0:0).&lt;br /&gt;
No such namespace: a&lt;br /&gt;
user=&amp;gt; (ex-data *e)&lt;br /&gt;
#:clojure.error{:phase :compile-syntax-check, :line 0, :column 0, :source &amp;quot;NO_SOURCE_PATH&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The syntax here is fine, just a is not a known namespace. &lt;br /&gt;
&lt;br /&gt;
The Compiler adheres to no patterns in differentiating between these two. We should go through and make this consistent, either through exception types or explicitly specifying the phase in a CompilerException.</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/4249/separate-compiler-exceptions-compilation-compile-syntax</guid>
<pubDate>Tue, 13 Nov 2018 21:05:29 +0000</pubDate>
</item>
<item>
<title>Confusing function name suffixes in error messages</title>
<link>https://ask.clojure.org/index.php/3773/confusing-function-name-suffixes-in-error-messages</link>
<description>Some core function names are reported in error messages with an odd munging suffix.&lt;br /&gt;
&lt;br /&gt;
For example, when passing the wrong number of arguments to {{inc}}, {{assoc}}, and {{dissoc}}, each error message reports the function name differently:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
clj -Srepro -Sdeps '{:deps {org.clojure/clojure {:mvn/version &amp;quot;1.10.0-beta4&amp;quot;}}}'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
user=&amp;gt; (inc)&lt;br /&gt;
Syntax error compiling inc at (1:1).&lt;br /&gt;
Wrong number of args (0) passed to: clojure.core/inc--inliner--5436&lt;br /&gt;
user=&amp;gt; (assoc)&lt;br /&gt;
Evaluation error (ArityException) at clojure.lang.AFn.throwArity (AFn.java:429).&lt;br /&gt;
Wrong number of args (0) passed to: clojure.core/assoc--5316&lt;br /&gt;
user=&amp;gt; (dissoc)&lt;br /&gt;
Evaluation error (ArityException) at clojure.lang.AFn.throwArity (AFn.java:429).&lt;br /&gt;
Wrong number of args (0) passed to: clojure.core/dissoc&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
From the user's point of view, this behaviour is unmotivated and confusing. Perhaps such names should be further demunged and printed without the suffix.</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/3773/confusing-function-name-suffixes-in-error-messages</guid>
<pubDate>Sat, 03 Nov 2018 13:01:54 +0000</pubDate>
</item>
<item>
<title>Multimethods don't have the correct method name in stacktraces.</title>
<link>https://ask.clojure.org/index.php/4231/multimethods-dont-have-the-correct-method-name-stacktraces</link>
<description>Describing the user-facing problem:&lt;br /&gt;
&lt;br /&gt;
When an exception is thrown and there is a multimethod in the stacktrace, the name of the multimethod is not shown in the callstack.&lt;br /&gt;
&lt;br /&gt;
When I execute this code:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(defmulti dispatcher (fn [item] (:type item)))&lt;br /&gt;
&lt;br /&gt;
(defmethod dispatcher &amp;quot;cat&amp;quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;[{:keys [lives]}]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;(/ lives 0))&lt;br /&gt;
&lt;br /&gt;
(dispatcher {:type &amp;quot;cat&amp;quot; :lives 9})&lt;br /&gt;
*e&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I get the following stack trace:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[clojure.lang.Numbers divide &amp;quot;Numbers.java&amp;quot; 163]&lt;br /&gt;
[clojure.lang.Numbers divide &amp;quot;Numbers.java&amp;quot; 3813]&lt;br /&gt;
[config_compilation.core$eval20467$fn__20469 invoke &amp;quot;/Users/marc/dev/circleci/orb-registry/server/src/config_compilation/core.clj&amp;quot; 198]&lt;br /&gt;
[clojure.lang.MultiFn invoke &amp;quot;MultiFn.java&amp;quot; 229]&lt;br /&gt;
... snip ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The function name is {{config_compilation.core$eval20467$fn__20469}}.&lt;br /&gt;
&lt;br /&gt;
If I use {{defn}} to declare {{dispatcher}} directly, I get the following stacktrace:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(defn dispatcher&lt;br /&gt;
&amp;nbsp;&amp;nbsp;[{:keys [lives]}]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;(/ lives 0))&lt;br /&gt;
&lt;br /&gt;
(dispatcher {:type &amp;quot;cat&amp;quot; :lives 9})&lt;br /&gt;
*e&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[clojure.lang.Numbers divide &amp;quot;Numbers.java&amp;quot; 163]&lt;br /&gt;
[clojure.lang.Numbers divide &amp;quot;Numbers.java&amp;quot; 3813]&lt;br /&gt;
[config_compilation.core$dispatcher invokeStatic &amp;quot;/Users/marc/dev/circleci/orb-registry/server/src/config_compilation/core.clj&amp;quot; 202]&lt;br /&gt;
[config_compilation.core$dispatcher invoke &amp;quot;/Users/marc/dev/circleci/orb-registry/server/src/config_compilation/core.clj&amp;quot; 200]&lt;br /&gt;
... snip ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The function name is given correctly as {{config_compilation.core$dispatcher}}.&lt;br /&gt;
&lt;br /&gt;
I'm guessing that the issue could be that the {{defmulti}} macro not setting the {{:name}} metadata, or perhaps not passing the {{:name}} metadata to the compiler correctly.</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/4231/multimethods-dont-have-the-correct-method-name-stacktraces</guid>
<pubDate>Mon, 22 Oct 2018 16:50:22 +0000</pubDate>
</item>
<item>
<title>Unfriendly Java cast expection when *compile-path* is set incorrectly</title>
<link>https://ask.clojure.org/index.php/3788/unfriendly-java-cast-expection-when-compile-path-incorrectly</link>
<description>When *compile-path* is not set to a String but to a java.io.File (that's what boot-clj does at the moment). You get a Cast exception in the compiler when trying to use it from the boot repl. Common wisdom seems to be to not compile from the repl, people say don't use gen-class. I find this unfortunate for when you do want to use gen-class and iterate quickly.&lt;br /&gt;
&lt;br /&gt;
I haven't tested all older versions for this issue, but git blame shows that the code that should help here wasn't changed for 10 years:&lt;br /&gt;
&lt;a href=&quot;https://github.com/clojure/clojure/blame/master/src/clj/clojure/core.clj#L6073&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;https://github.com/clojure/clojure/blame/master/src/clj/clojure/core.clj#L6073&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/clojure/clojure/blame/master/src/jvm/clojure/lang/Compiler.java#L7643&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;https://github.com/clojure/clojure/blame/master/src/jvm/clojure/lang/Compiler.java#L7643&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
My workaround now is:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(defn compile-safely [ns-name]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;(let [compile-path-class *compile-path*&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;corrected-path (cond&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(instance? java.io.File compile-path-class) (.getAbsolutePath *compile-path*)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(instance? String compile-path-class) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*compile-path*&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;:else&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(throw (ex-info &amp;quot;Unsupported class&amp;quot; {:class (class compile-path-class)})))]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(binding [*compile-path* corrected-path]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(compile ns-name))))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I suggest to put the type check in the 'clojure.core/compile function.</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/3788/unfriendly-java-cast-expection-when-compile-path-incorrectly</guid>
<pubDate>Thu, 04 Oct 2018 09:55:23 +0000</pubDate>
</item>
<item>
<title>Omit &quot;null&quot; Exception message from error output</title>
<link>https://ask.clojure.org/index.php/3832/omit-null-exception-message-from-error-output</link>
<description>&lt;p&gt;Current:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;user=&amp;gt; ((do nil))
Evaluation error at user/eval4 (NO_SOURCE_FILE:3). NullPointerException null&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;After patch:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;user=&amp;gt; ((do nil))
Evaluation error at user/eval4 (NO_SOURCE_FILE:3). NullPointerException &lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Patch:&lt;/strong&gt; 0001-CLJ-2420-ignore-null-Exception-message-v2.patch&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Prescreened by:&lt;/strong&gt; Alex Miller&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/3832/omit-null-exception-message-from-error-output</guid>
<pubDate>Wed, 05 Sep 2018 13:29:40 +0000</pubDate>
</item>
<item>
<title>clojure.test/is + thrown-with-msg? error when caught exception message is nil</title>
<link>https://ask.clojure.org/index.php/4213/clojure-test-thrown-with-error-when-caught-exception-message</link>
<description>&lt;p&gt;&lt;strong&gt;Steps:&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;&lt;code&gt;(require '[clojure.test :refer [is]])
(is (thrown-with-msg? Exception #&quot;123&quot; (throw (ex-info nil {}))))&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Expected&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;FAIL in () (form-init1933636226458515246.clj:1)
expected: (thrown-with-msg? Exception #&quot;123&quot; (throw (ex-info nil {})))
  actual: ...&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Actual&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
ERROR in () (Matcher.java:1283)&lt;br&gt;
expected: (thrown-with-msg? Exception #&quot;123&quot; (throw (ex-info nil {})))&lt;br&gt;
  actual: java.lang.NullPointerException: null&lt;br&gt;
 at java.util.regex.Matcher.getTextLength (Matcher.java:1283)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;java.util.regex.Matcher.reset (Matcher.java:309)
java.util.regex.Matcher.&amp;lt;init&amp;gt; (Matcher.java:229)
java.util.regex.Pattern.matcher (Pattern.java:1093)
clojure.core$re_matcher.invokeStatic (core.clj:4796)
clojure.core$re_find.invokeStatic (core.clj:4838)
clojure.core$re_find.invoke (core.clj:4838)
user$eval43312.invokeStatic (form-init1933636226458515246.clj:1)
user$eval43312.invoke (form-init1933636226458515246.clj:1)
clojure.lang.Compiler.eval (Compiler.java:7062)
clojure.lang.Compiler.eval (Compiler.java:7025)
clojure.core$eval.invokeStatic (core.clj:3206)
clojure.core$eval.invoke (core.clj:3202)
clojure.main$repl$read_eval_print__8572$fn__8575.invoke (main.clj:243)
clojure.main$repl$read_eval_print__8572.invoke (main.clj:243)
clojure.main$repl$fn__8581.invoke (main.clj:261)
clojure.main$repl.invokeStatic (main.clj:261)
clojure.main$repl.doInvoke (main.clj:177)
clojure.lang.RestFn.invoke (RestFn.java:1523)
clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__40865.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:657)
clojure.core$with_bindings_STAR_.invokeStatic (core.clj:1965)
clojure.core$with_bindings_STAR_.doInvoke (core.clj:1965)
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__40910$fn__40913.invoke (interruptible_eval.clj:222)
clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__40905.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)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;ClojureScript:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;ERROR in () (TypeError:NaN:NaN)
expected: (thrown-with-msg? js/Error #&quot;123&quot; (throw (ex-info nil {})))
  actual: #object[TypeError TypeError: re-find must match against a string.]&lt;/code&gt;&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/4213/clojure-test-thrown-with-error-when-caught-exception-message</guid>
<pubDate>Fri, 29 Jun 2018 22:41:03 +0000</pubDate>
</item>
<item>
<title>Improve error message when calling a keyword with the wrong number of arguments</title>
<link>https://ask.clojure.org/index.php/4246/improve-error-message-calling-keyword-wrong-number-arguments</link>
<description>&lt;p&gt;When you call a {{Keyword}} with the wrong number of arguments, the error message does not report how many arguments were passed:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;(:kw &quot;one&quot; &quot;two&quot; &quot;three&quot;)
=&amp;gt; java.lang.IllegalArgumentException: Wrong number of args passed to keyword: :kw&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;compare to calling an {{IFn}}, which does show the number of arguments passed:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;(name &quot;one&quot; &quot;two&quot; &quot;three&quot;)
=&amp;gt; clojure.lang.ArityException: Wrong number of args (3) passed to: core/name&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The latter error message is more clear and makes it easier to debug.&lt;/p&gt;
&lt;p&gt;The attached patch re-uses the {{ArityException}} class used elsewhere to generate error messages in the latter form when calling a keyword with the wrong number of arguments.&lt;/p&gt;
&lt;p&gt;Addresses CLJ-1067&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Patch:&lt;/strong&gt; keyword-arity-exception-03.patch&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Screened by:&lt;/strong&gt; Alex Miller&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/4246/improve-error-message-calling-keyword-wrong-number-arguments</guid>
<pubDate>Thu, 03 May 2018 13:46:34 +0000</pubDate>
</item>
<item>
<title>clojure.lang.ExceptionInfo should not pass null cause in its two-arg constructor</title>
<link>https://ask.clojure.org/index.php/2776/clojure-lang-exceptioninfo-should-pass-cause-constructor</link>
<description>&lt;p&gt;The two-arg constructor for clojure.lang.ExceptionInfo chains to the 3-arg version, passing null as the cause. The 3-arg constructor then calls super with the null cause, above which line is the comment &quot;null cause is equivalent to not passing a cause&quot;.&lt;/p&gt;
&lt;p&gt;This is not actually true, as passing null here means the cause has been initialised, regardless of value. As a consequence, you can not call .initCause on the ex-info exception later. In my case, the 'cause' is not known when thrown: the exception is caught upstack, the cause added, then rethrown.&lt;/p&gt;
&lt;p&gt;In summary, this expression will always throw an exception: (-&amp;gt; (ex-info &quot;ex&quot; {}) (.initCause (Exception. &quot;cause&quot;))).&lt;/p&gt;
&lt;p&gt;The simple solution would be to call the 2-arg super, and call .initCause if cause is non-null.&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Matt.&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/2776/clojure-lang-exceptioninfo-should-pass-cause-constructor</guid>
<pubDate>Sun, 11 Feb 2018 00:51:48 +0000</pubDate>
</item>
<item>
<title>Line numbers in stack trace are wrong when type hints satisfaction fails</title>
<link>https://ask.clojure.org/index.php/4215/line-numbers-stack-trace-wrong-when-hints-satisfaction-fails</link>
<description>&lt;p&gt;When I run the following file&lt;/p&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
(defn f [^double x] x)&lt;/p&gt;
&lt;p&gt;(defn g []&lt;br&gt;
  (println)&lt;br&gt;
  (f nil))&lt;/p&gt;
&lt;p&gt;(g)&lt;br&gt;
&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;I get the following stack trace&lt;/p&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
Exception in thread &quot;main&quot; java.lang.NullPointerException, compiling:(/.../example.clj:7:1)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;at clojure.lang.Compiler.load(Compiler.java:7526)
at clojure.lang.Compiler.loadFile(Compiler.java:7452)
at clojure.main$load_script.invokeStatic(main.clj:278)
at clojure.main$script_opt.invokeStatic(main.clj:338)
at clojure.main$script_opt.invoke(main.clj:333)
at clojure.main$main.invokeStatic(main.clj:424)
at clojure.main$main.doInvoke(main.clj:387)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:702)
at clojure.main.main(main.java:37)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Caused by: java.lang.NullPointerException&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;at clojure.lang.RT.doubleCast(RT.java:1348)
at user$g.invokeStatic(example.clj:4)
at user$g.invoke(example.clj:3)
at user$eval147.invokeStatic(example.clj:7)
at user$eval147.invoke(example.clj:7)
at clojure.lang.Compiler.eval(Compiler.java:7062)
at clojure.lang.Compiler.load(Compiler.java:7514)
... 9 more
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The line {{at user$g.invokeStatic(example.clj:4)}} here is quite misleading, because the error happens at line 5.&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/4215/line-numbers-stack-trace-wrong-when-hints-satisfaction-fails</guid>
<pubDate>Mon, 27 Nov 2017 05:02:14 +0000</pubDate>
</item>
<item>
<title>When calling a multi method with the wrong number of arguments, the error message could be better.</title>
<link>https://ask.clojure.org/index.php/2803/calling-multi-method-wrong-number-arguments-message-better</link>
<description>&lt;br /&gt;
09:43 $ clj&lt;br /&gt;
Clojure 1.8.0&lt;br /&gt;
(defmulti foo :bar)&lt;br /&gt;
(defmethod foo :qix [quux znoot] (println 'hi))&lt;br /&gt;
#'user/foo&lt;br /&gt;
user=&amp;gt; #object[clojure.lang.MultiFn 0x205d38da &amp;quot;clojure.lang.MultiFn@205d38da&amp;quot;]&lt;br /&gt;
user=&amp;gt; (foo {:bar :qix})&lt;br /&gt;
ArityException Wrong number of args (1) passed to: user/eval5/fn--6 &amp;nbsp;clojure.lang.AFn.throwArity (AFn.java:429)&lt;br /&gt;
user=&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is an implementation detail that multi methods are implemented via anonymous functions. I would expect the error message to at least contain the name of the function that failed, in this case it should have been something like &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ArityException Wrong number of args (1) passed to: user/eval5/foo--6 &amp;nbsp;clojure.lang.AFn.throwArity (AFn.java:429)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Several approaches can be taken here:&lt;br /&gt;
&lt;br /&gt;
The first (and simplest) is to change the definition of {{defmethod}} so that the anonymous function gets a name.&lt;br /&gt;
This leads to an error message like: &lt;br /&gt;
&lt;br /&gt;
user=&amp;gt; (defmulti foo :bar)&lt;br /&gt;
(defmethod foo :qix [quux znoot] (println 'hi))&lt;br /&gt;
(foo {:bar :qix})#'user/foo&lt;br /&gt;
user=&amp;gt; #object[clojure.lang.MultiFn 0x4e928fbf &amp;quot;clojure.lang.MultiFn@4e928fbf&amp;quot;]&lt;br /&gt;
user=&amp;gt;&lt;br /&gt;
ArityException Wrong number of args (1) passed to: user/eval5/foo--6 &amp;nbsp;clojure.lang.AFn.throwArity (AFn.java:429)&lt;br /&gt;
user=&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In addition to this, one could modify Compiler.java to look for the calls to &amp;quot;addMethod&amp;quot;&lt;br /&gt;
&lt;br /&gt;
String prefix = &amp;quot;eval&amp;quot;;&lt;br /&gt;
if (RT.count(form) &amp;gt; 2) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Object third = RT.nth(form, 2);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;if (third != null &amp;amp;&amp;amp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot;clojure.core/addMethod&amp;quot;.equals(third.toString()))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;prefix = &amp;quot;multi_fn&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
ObjExpr fexpr = (ObjExpr) analyze(C.EXPRESSION, RT.list(FN, PersistentVector.EMPTY, form), prefix + RT.nextID());&lt;br /&gt;
&lt;br /&gt;
which would give us error messages like&lt;br /&gt;
&lt;br /&gt;
ArityException Wrong number of args (1) passed to: user/multi-fn5/foo--6 &amp;nbsp;clojure.lang.AFn.throwArity (AFn.java:441)&lt;br /&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/2803/calling-multi-method-wrong-number-arguments-message-better</guid>
<pubDate>Tue, 07 Nov 2017 15:10:17 +0000</pubDate>
</item>
<item>
<title>LispReader.java  and EdnReader.java exception messages could be much more informative.</title>
<link>https://ask.clojure.org/index.php/3364/lispreader-ednreader-exception-messages-could-informative</link>
<description>&lt;p&gt;The messages in the exceptions thrown by the readers would be much more informative if they included readily available information. There are many instances of this, but to name a few specific instances (all from LispReader.java, though there in most cases there are corresponding problems in EdnReader.java):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If the RegexReader class hits an unexpected EOF, it reports &quot;EOF while reading regex&quot;. It would be helpful if the message included the first few characters of the regex it was trying to read -- available in sb -- as a guide to the person trying to locate the problem.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The same logic applies to StringReader.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In NamespaceMapReader, the error thrown if the namespaced map is not in fact a map could include the namespace symbol.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Whenever an odd number of elements in a map is detected, the exception could at least report the number of elements that the bad map did include, something like: &quot;Map literal cannot contain 7 forms. Map literals must contain an even number of forms.&quot; Even better would be the first few forms.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &quot;Metadata can only be applied to IMetas&quot; exception in MetaReader is not nearly as helpful as it could be. At the very least it should report the class of the thing that is not an IMeta.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;With an additional argument, readDelimitedList could report the kind of thing that it was reading in the event that it hit the EOF. Without the additional argument it still report that it hit an EOF while trying to read the first or 4th or 29 element of a collection.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/3364/lispreader-ednreader-exception-messages-could-informative</guid>
<pubDate>Wed, 31 May 2017 20:13:55 +0000</pubDate>
</item>
<item>
<title>Error message for non integer index into vector could be improved.</title>
<link>https://ask.clojure.org/index.php/2804/error-message-for-integer-index-into-vector-could-improved</link>
<description>&lt;p&gt;The exception generated in APersistentVector/invoke and also in APersistentVector/assoc when the index is not an integer would be better if it included the class of the object actually passed in and would be better still if it included the actual value.&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/2804/error-message-for-integer-index-into-vector-could-improved</guid>
<pubDate>Wed, 31 May 2017 19:49:07 +0000</pubDate>
</item>
<item>
<title>Catch multiple exceptions in a single catch block</title>
<link>https://ask.clojure.org/index.php/2784/catch-multiple-exceptions-in-a-single-catch-block</link>
<description>&lt;p&gt;Java 7 and up support multi-catch exceptions (&lt;a rel=&quot;nofollow&quot; href=&quot;http://www.oracle.com/technetwork/articles/java/java7exceptions-486908.html&quot;&gt;http://www.oracle.com/technetwork/articles/java/java7exceptions-486908.html&lt;/a&gt;). It would be handy if Clojure also supported them to prevent catching something like Exception and then writing manual logic to check the Exception type, or duplicating the logic over multiple catch blocks.&lt;/p&gt;
&lt;p&gt;A possible syntax for this could be:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
(try (fn-that-throws)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; (catch (UnknownHostException NoRouteToHostException) e
   (go-offline)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Prior art for this is a                     *  } macro: &lt;a rel=&quot;nofollow&quot; href=&quot;https://gist.github.com/Gonzih/5814945&quot;&gt;https://gist.github.com/Gonzih/5814945&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;One nuance to handle is &lt;/p&gt;
&lt;p&gt;{quote}&lt;br&gt;
Edit: Note that in Java 7, you cannot both catch ExceptionA&amp;amp; ExceptionB in the same time, if ExceptionB is inherited(directly or indirectly) from ExceptionA. Compiler will complain: The exception ExceptionB is already caught by the alternative ExceptionA. - &lt;a rel=&quot;nofollow&quot; href=&quot;http://stackoverflow.com/a/3495968/826486&quot;&gt;http://stackoverflow.com/a/3495968/826486&lt;/a&gt;&lt;br&gt;
{quote}&lt;/p&gt;
&lt;p&gt;I tried searching to see if this had been asked already, but got mountains of results. I didn't see anything in the first few pages though.&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/2784/catch-multiple-exceptions-in-a-single-catch-block</guid>
<pubDate>Sun, 12 Mar 2017 22:56:47 +0000</pubDate>
</item>
<item>
<title>Provide meaning error message when eval of function fails.</title>
<link>https://ask.clojure.org/index.php/755/provide-meaning-error-message-when-eval-of-function-fails</link>
<description>&lt;p&gt;When attempting to eval a function, in some cases this fails with &quot;No matching ctor found&quot;. This error does not clearly indicate the root cause. Suggest something like &quot;cannot eval function&quot; or something similar. See &lt;a rel=&quot;nofollow&quot; href=&quot;http://dev.clojure.org/jira/browse/CLJ-1206&quot;&gt;http://dev.clojure.org/jira/browse/CLJ-1206&lt;/a&gt; for history relating to this ticket.&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/755/provide-meaning-error-message-when-eval-of-function-fails</guid>
<pubDate>Sun, 15 May 2016 12:04:06 +0000</pubDate>
</item>
<item>
<title>Bad type hints on a defn cause the compiler to throw a NPE</title>
<link>https://ask.clojure.org/index.php/2369/bad-type-hints-on-a-defn-cause-the-compiler-to-throw-a-npe</link>
<description>&lt;p&gt;After CLJ-1232 was committed to master, it is possible for the Clojure compiler to throw a NPE if a defn is type hinted with a invalid type. This surfaces in CLJS where the defn macro is re-used by the ClojureScript compiler, but I think it raises the question: &quot;Should a bad type hint result in a compiler exception?&quot;&lt;/p&gt;
&lt;p&gt;The offending line can be found here on GitHub: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L247&quot;&gt;https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L247&lt;/a&gt;&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/2369/bad-type-hints-on-a-defn-cause-the-compiler-to-throw-a-npe</guid>
<pubDate>Fri, 04 Dec 2015 19:16:32 +0000</pubDate>
</item>
</channel>
</rss>