r/Clojure • • Aug 11 '18

Error message improvements in Clojure 1.10

https://mobile.twitter.com/puredanger/status/1028103654241443840
89 Upvotes

41 comments sorted by

View all comments

4

u/didibus Aug 11 '18

One more question, you mention ex-data is now part of all exceptions? Can you clarify what that means?

What will the ex-data map look like? Does it mean we can start relying on ex-data to identify the exact kind of exceptions for all of core? Will ex-data have a spec?

Thanks

2

u/alexdmiller Aug 11 '18

One more question, you mention ex-data is now part of all exceptions?

Not all, but CompilerException wrappers now implement IExceptionInfo and have ex-data. These are the important ones to convey the location in the user's source being read/macroexpanded/compiled. Runtime errors will just flow as is, so it's up to you to throw ex-info where you want to.

What will the ex-data map look like?

Here's a wip example, won't commit to any of this yet:

{:clojure.error/line 69, 
:clojure.error/column 1, 
:clojure.error/phase :clojure.phase/spec, 
:clojure.error/source "NO_SOURCE_PATH", 
:clojure.error/symbol clojure.core/let}

Does it mean we can start relying on ex-data to identify the exact kind of exceptions for all of core?

No? Not sure what you mean though.

Will ex-data have a spec?

Not sure if you mean the function (probably not worth it) or the attributes, which we could do but not sure it's buying you much:

(s/def :clojure.error/line int?)
(s/def :clojure.error/column int?)
(s/def :clojure.error/phase (s/nilable qualified-keyword?))
(s/def :clojure.error/source (s/nilable string?))
(s/def :clojure.error/symbol (s/nilable symbol?))
etc