Problems

Symptoms

Example Use Cases

Constraints

An even-more modest proposal

I think we should implement

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 that is often done via exceptions on other JVM languages.

clj-stacktrace

Ad hoc conditions

E.g. Contrib Condition or Contrib Error-Kit.

Not carrying this idea forward at this point.

Pattern Matching Conditions

Pattern matching (a la Matchure), plus exceptions as data, plus dynamic binding.

Not carrying this idea forward at this point.

Data-carrying exception

Single exception type that can carry data, allowing clojure data tools to be used to process exceptions.

Enrich exceptions with local context

Bindable test/assertion handler

Bindable throw handler

Platform-based handler

Is there JVM support for automating handlers like the assert handler or throw handler? If these exist, and are flexible and easy to deploy, could use them instead of extending Clojure.

Bindable edge handler

Weaknesses of the modest proposal