ClojureScript

Data Conveying Exception: ex-data and ex-info

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Activity

Michał Marczyk made changes -
Assignee Michał Marczyk [ michalmarczyk ]
Hide
Michał Marczyk added a comment -

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).

Show
Michał Marczyk added a comment - 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).
Michał Marczyk made changes -
Attachment 0001-CLJS-429-Data-Conveying-Exception-ex-data-and-ex-inf.patch [ 11747 ]
Hide
Michał Marczyk added a comment -

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).

Show
Michał Marczyk added a comment - 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).
Michał Marczyk made changes -
Michał Marczyk made changes -
Attachment 0001-CLJS-429-Data-Conveying-Exception-ex-data-and-ex-inf.patch [ 11747 ]
Hide
Michał Marczyk added a comment -

Clojure patch @ CLJ-1120.

Show
Michał Marczyk added a comment - Clojure patch @ CLJ-1120.
David Nolen made changes -
Resolution Completed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
David Nolen made changes -
Status Resolved [ 5 ] Closed [ 6 ]

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: