API for condition - clojure-contrib v1.2 (stable)

by Stephen C. Gilardi

clojure-contrib is now deprecated

clojure-contrib is no longer being developed or maintained.

Rather than a single, monolithic, contributions library, Clojure now has a set of separate libraries for each unit of functionality. The libraries are in the Clojure GitHub organization at https://github.com/clojure. API documentation of the libraries can be found at https://clojure.github.io.

If you're looking for a specific function or namespace from the old clojure-contrib, see "Where Did Clojure.Contrib Go".


Full namespace name: 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



*full-stack-traces*

var
This library, clojure-contrib, is deprecated. See here for more information.

  
Bind to true to include clojure.{core,lang,main} frames in stack
traces
Source


handler-case

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (handler-case dispatch-fn & body)
Executes body in a context where raised conditions can be handled.

dispatch-fn accepts a raised condition (a map) and returns a selector
used to choose a handler. Commonly, dispatch-fn will be :type to dispatch
on the condition's :type value.

Handlers are forms within body:

  (handle key
    ...)

If a condition is raised, executes the body of the first handler whose
key satisfies (isa? selector key). If no handlers match, re-raises the
condition.

While a handler is running, *condition* is bound to the condition being
handled and *selector* is bound to to the value returned by dispatch-fn
that matched the handler's key.
Source


print-stack-trace

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (print-stack-trace x)
Prints a stack trace for a condition or Throwable. Skips frames for
classes in clojure.{core,lang,main} unless the *full-stack-traces* is
bound to logical true
Source


raise

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (raise)
       (raise m)
       (raise key val & keyvals)
Raises a condition. With no arguments, re-raises the current condition.
With one argument (a map), raises the argument. With two or more
arguments, raises a map with keys and values from the arguments.
Source


stack-trace-info

multimethod
This library, clojure-contrib, is deprecated. See here for more information.
No usage documentation available
Returns header, stack-trace, and cause info from conditions and
Throwables
Source

condition.Condition






-init

function
This library, clojure-contrib, is deprecated. See here for more information.
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.
Source

-meta

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (-meta this)
Returns this object's metadata, the condition
Source

-post-init

function
This library, clojure-contrib, is deprecated. See here for more information.
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.
Source
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.