Constraints

where exceptions are used for exceptional things, performance is not an issue

error handling should unify at bottom with Java

neither ordinary nor exceptional things should have to pollute API for fns that don't care or can't respond

pay for what you need

An even-more modest proposal

I think we should implement

education on dynamic bindings

bindable *assertion-handler*

(maybe) clj-stacktrace-like data-ification fns for exceptions

(maybe) data-carrying *RuntimeException* subclass

All of these ideas, and several others not chosen, are documented below.

Some approaches

Table of some approaches and how they address the problems above. Approaches described in more detail below. Some of the approaches are deliberately crazy for contrast (wonder if we will agree on which ones).

Approach

Type Dispatch

Data Payloads

Out-of-band Communication

Action at Point of Exception

Exceptions as Data

Notes

education on dynamic binding

solves

n/a

solves

could solve

n/a

clj-stacktrace

should unify with dataification of exceptions, if any

n/a

n/a

n/a

partially solves for non-Clojure types

ad hoc conditions

worsens

could solve

worsens

solves

orthogonal

worsens = replaces general mechanism with more specialized one

pattern-matching conditions

?

could solve

worsens

solves

orthogonal

worsens = replaces general mechanism with more specialized one

data-carrying exception

could support pattern matching

solves

n/a

n/a

solves for Clojure types

enrich exceptions with local context

n/a

enhanced

for errors only

n/a

enhanced

yuck: makes everybody pay for debug time support

bindable test/assertion handler

orthogonal

orthogonal

for assertions

for assertions

n/a

bindable throw handler

orthogonal

orthogonal

for Clojure exceptions

for Clojure exceptions

n/a

platform-based handler

orthogonal

orthogonal

solves

solves

n/a

does it exist?

bindable edge handler

orthogonal

orthogonal

tries and fails

tries and fails

could help

yuck: perf, asymmetry, doesn't accomplish desired goal

wrap java exceptions

orthogonal

orthogonal

at Clojure boundary

n/a

could support

yuck; terrible perf, terrible asymmetry, or both

"modest proposal" above

solves

solves

solves, with extra goodness for debug

solves, with extra goodness for debug

solves

what's not to like? see bottom of this page...

Education on Dynamic Binding

Document dynamic binding as the Clojure Way to do out-of-band-control flow

find likely place within Clojure or Contrib and implement examplar

write docs and tutorial

add "control flow" link from exception handling parts of Clojure docs

Clj-stacktrace

define a standard vocabulary for data-izing the information in a clojure exception

package in fns

do not call these fns automatically

maybe provide REPL helpers that do

other parts of clj-stactkrace (color printing etc.) should remain tool features