Data Conveying Exception

Description

Problem: need to convey diagnostic information in an exception, and Java exceptions are poor for this because they don't have any place to put data. Having many apps write their own exceptions is unnecessary code bloat, and sometimes has compilation implications.

Choices made:

  • Naming it ExceptionInfo. Needs to tell the user that it carries data, without suggesting that there was a problem with data.

    • think we have to include Exception in the name, esp. for interop consumers.

  • Class of data member. IPersistentMap

  • Class of map input. IPersistentMap

  • Do not want to build anything to support conditional logic. (Use bindings for this).

  • Base class. RuntimeException is consistent with a dynamic language (don't want to impose checked exceptions).

  • print with data just after msg on first line

  • equality by identity (pretty much dictated by having exception as base class)

  • ex-info factory function

  • ex-data fn to get the data out

  • data and msg arguments required

  • data argument comes second

    • matches Java expectation of msg first, cause last

    • matches print order

Environment

None

Attachments

6
  • 02 Dec 2011, 04:07 PM
  • 21 Oct 2011, 04:21 PM
  • 16 Oct 2011, 12:06 PM
  • 14 Oct 2011, 06:52 PM
  • 28 Jan 2011, 08:47 PM
  • 28 Jan 2011, 08:14 PM

Activity

Show:

Hugo Duncan December 5, 2011 at 10:53 PM

ex-info and ex-data seem rather terse names to me (exception-info and exception-data would be clearer, imho). Clojure seems to have a mixture of abbreviated names and full names, but it was my vague impression that most of the abbreviations stemmed from traditional lisp or java usage.

Stuart Sierra December 3, 2011 at 6:06 PM

Screened & moved to Approved Backlog.

Stuart Halloway December 2, 2011 at 4:32 PM

The dec 2 edition does the arg check in the constructor and uses pr-str, addressing the last two comments raised.

Stuart Halloway December 2, 2011 at 4:07 PM

The dec 2 edition does the arg check in the constructor and uses pr-str, addressing the last two comments raised.

Stuart Sierra December 2, 2011 at 3:21 PM

Setting to 'Incomplete' pending response to 2 previous comments.

Completed

Details

Assignee

Reporter

Approval

Ok

Patch

Code and Test

Priority

Fix versions

Created January 28, 2011 at 7:59 PM
Updated July 26, 2013 at 4:35 PM
Resolved July 26, 2013 at 4:35 PM

Flag notifications