<< Back to previous view

[CLJS-429] Data Conveying Exception: ex-data and ex-info Created: 26/Nov/12  Updated: 27/Jul/13  Resolved: 06/Dec/12

Status: Closed
Project: ClojureScript
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Dave Sann Assignee: Michał Marczyk
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File 0001-CLJS-429-Data-Conveying-Exception-ex-data-and-ex-inf.patch    


equivalent of http://dev.clojure.org/jira/browse/CLJ-733

as per https://groups.google.com/d/topic/clojure/vlTR_161WNc/discussion

see also:



Comment by Michał Marczyk [ 05/Dec/12 5:47 PM ]

The attached patch introduces ex-info, ex-data and ExceptionInfo to cljs.core. ExceptionInfo has its prototype set to Error.prototype (apparently necessary for good behaviour across browsers; this is marked as a special case in a comment).

The version of ex-info introduced by the patch does support a cause argument, but I have to say that it's not clear to me how user code should go about extracting it. Direct property access feels icky; a new fn would be possible, but should perhaps be shared with Clojure; Clojure code would say (.getCause ex), but hanging a method on ExceptionInfo somehow feels icky to me too. My first cut at the patch actually did not include the cause field in ExceptionInfo and the ternary variant of ex-info; that could actually be a reasonable approach for now, especially if introducing a new fn might be a possibility (since that would presumably require coordination with Clojure).

Comment by Michał Marczyk [ 06/Dec/12 6:17 AM ]

An improved patch. Firstly, it correctly makes ExceptionInfo into a custom error type (the original patch was broken on this point). Secondly, it introduces ex-message and ex-cause for dealing with ExceptionInfo in a platform-agnostic manner (got the go-ahead from Rich @ ClojureX; I'll be submitting a patch for this to Clojure).

Comment by Michał Marczyk [ 06/Dec/12 6:23 AM ]

Clojure patch @ CLJ-1120.

Comment by David Nolen [ 06/Dec/12 10:18 AM ]

fixed, http://github.com/clojure/clojurescript/commit/7ccb67e040d32b2c0112d2c73dd2e28d5e13c50a

Generated at Thu Oct 08 11:32:35 CDT 2015 using JIRA 4.4#649-r158309.