API for condition
(1.1.x branch)
by
Stephen C. Gilardi
Usage:
(ns your-namespace
(:require clojure.contrib.condition))
Overview
Flexible raising and handling of conditions:
Functions:
raise: raises a condition
handler-case: dispatches raised conditions to appropriate handlers
print-stack-trace: prints abbreviated or full condition stack traces
Data:
A condition is a map containing values for these keys:
- :type, a condition type specifier, typically a keyword
- :stack-trace, a stack trace to the site of the raise
- :message, a human-readable message (optional)
- :cause, a wrapped exception or condition (optional)
- other keys given as arguments to raise (optional)
Note: requires AOT compilation.
Based on an idea from Chouser:
http://groups.google.com/group/clojure/browse_frm/thread/da1285c538f22bb5
Public Variables and Functions
condition.Condition
-init
function
Usage: (-init condition)
Constructs a Condition object with condition (a map) as its
metadata. Also initializes the superclass with the values at :message
and :cause, if any, so they are also available via .getMessage and
.getCause.
function
Usage: (-meta this)
Returns this object's metadata, the condition
-post-init
function
Usage: (-post-init this condition)
Adds :stack-trace to the condition. Drops the bottom 3 frames because
they are always the same: implementation details of Condition and raise.