We're updating the issue view to help you get more done. 

IExceptionInfo should print with its ex-data

Description

The new (for 1.7) data-reader printing format for exceptions does not include the ex-data when relevant:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 user> *clojure-version* {:major 1, :minor 7, :incremental 0, :qualifier "beta2"} user> (pr (ex-info "msg" {:my-data 42})) #error { :cause "msg" :via [{:type clojure.lang.ExceptionInfo :message "msg" :at [clojure.core$ex_info invoke "core.clj" 4591]}] :trace [[clojure.core$ex_info invoke "core.clj" 4591] [user$eval9314 invoke "form-init6701752258113826186.clj" 1] ;; ... ]}

Approach: If ExceptionInfo is caught, also print :data key with ex-data. Include :data key for each ExceptionInfo in via.

After:

1 2 3 4 5 6 7 8 9 10 11 12 13 #error { :cause "msg" :data {:my-data 42} :via [{:type clojure.lang.ExceptionInfo :message "msg" :data {:my-data 42} :at [clojure.core$ex_info invoke "core.clj" 4591]}] :trace [[clojure.core$ex_info invoke "core.clj" 4591] [user$eval1 invoke "NO_SOURCE_FILE" 1] ;; elided ]}

Example with nested ExceptionInfo:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 (try (throw (ex-info "cause" {:a :b})) (catch Exception e (throw (ex-info "wrapped" {:c :d} e)))) ;; yields: #error { :cause "cause" :data {:a :b} :via [{:type clojure.lang.ExceptionInfo :message "wrapped" :data {:c :d} :at [clojure.core$ex_info invoke "core.clj" 4591]} {:type clojure.lang.ExceptionInfo :message "cause" :data {:a :b} :at [clojure.core$ex_info invoke "core.clj" 4591]}] :trace [[clojure.core$ex_info invoke "core.clj" 4591] [user$eval5 invoke "NO_SOURCE_FILE" 4] ;; elided ]}

Patch: CLJ-1716.patch

Environment

None

Status

Assignee

Unassigned

Reporter

gfredericks

Labels

Approval

Ok

Patch

Code and Test

Fix versions

Affects versions

Release 1.7

Priority

Major