improvements to exception messages and printing

Description

Port to ClojureScript.

Environment

None

Activity

Show:
Mike Fikes
December 2, 2018, 10:40 PM

CLJS-2913.patch passes CI

Mike Fikes
December 2, 2018, 9:42 PM

Much of the new source in cljs.repl is a direct copy of the relevant code from clojure.main. Why is it copied into into cljs.repl? That's where much of the other similar code copied from clojure.main already lives.

In general, the revisions amount to ensuring that exceptions have :clojure.error/phase ex-data on them. As in Clojure, many of the existing exceptions are just chained onto a new exception as the cause.

For cljs.analyzer, this is done / ensured in the wrapping-errors macro. Elsewhere in the code cljs.compiler, cljs.closure, etc, a util/compilation-error helper is used to effect the desired chaining.

As in Clojure, this results in a need to revise many tests to look at cause messages instead of the top-level exception messages, and as in Clojure a thrown-with-cause-msg? facility is copied over to ease transitioning to these kinds of tests.

There is a bit of Clojure code that depends on clojure.spec.alpha being loaded. This hard dependency is eliminated in cljs.repl by instead using resolve for now.

There is also some destructuring code that uses newer :<namespace-name>/keys syntax which is avoided to get things to compile with Clojure 1.8.

Mike Fikes
November 27, 2018, 1:31 AM

WIP in this branch towards ultimately producing a patch for review: https://github.com/mfikes/clojurescript/tree/CLJS-2913-WIP

Ben Brinckerhoff
November 25, 2018, 11:44 PM

https://github.com/clojure/clojurescript/commit/5f0fabc65ae7ba201b32cc513a1e5931a80a2bf7 makes CLJS spec reporting behave like CLJ, which is excellent.

However, until CLJS also ports over the error reporting code in CLJ (which will format spec errors using "explain-out"), users cannot use a third-party spec reporter e.g. expound

For comparison, here is what happens in CLJ

Completed

Assignee

Mike Fikes

Reporter

Mike Fikes

Labels

None

Approval

Accepted

Patch

Code and Test

Priority

Blocker