Details
-
Type:
Enhancement
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Completed
-
Affects Version/s: None
-
Fix Version/s: Approved Backlog
-
Component/s: None
-
Labels:None
-
Patch:Code and Test
-
Approval:Ok
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
Looks good; Stu's patch was missing a forward declaration to print-defrecord. 0733-data-conveying-exception-2.patch adds one, and all tests pass.