Conditions, protocol for communicating the causes of exceptions.
This provides infrastructure for building condition objects. A condition object provides information about the cause of an exception. Conditions thus form a protocol.
Clojure ex-info
objects do not, by themselves, enough to form such
a protocol, as they do not allow classifying an exception easily.
This condition system builds on the design of R6RS Scheme.
Condition objects are represented as specially marked ex-info
objects.
One notable difference to the R6RS design is that there is no user-facing type for 'simple conditions', nor are they regular records.
Conditions, protocol for communicating the causes of exceptions. This provides infrastructure for building *condition* objects. A condition object provides information about the cause of an exception. Conditions thus form a protocol. Clojure `ex-info` objects do not, by themselves, enough to form such a protocol, as they do not allow classifying an exception easily. This condition system builds on the design of [R6RS Scheme](http://www.r6rs.org/final/html/r6rs-lib/r6rs-lib-Z-H-8.html#node_sec_7.2). Condition objects are represented as specially marked `ex-info` objects. One notable difference to the R6RS design is that there is no user-facing type for 'simple conditions', nor are they regular records.
Violation of a specific assertion.
Violation of a specific assertion.
Root of the condition-type hierarchy.
Root of the condition-type hierarchy.
Error from environment, not preventable by the program.
Error from environment, not preventable by the program.
Condition with objects providing more information about an exceptional situation.
irritants
(objects providing more information): access via active.clojure.condition/condition-irritants
Condition with objects providing more information about an exceptional situation. `irritants` (objects providing more information): access via [[active.clojure.condition/condition-irritants]]
Location information about an exceptional situation
namespace
(namespace of the location): access via active.clojure.condition/location-condition-namespace
file
(file name of the location): access via active.clojure.condition/location-condition-file
line
(line number of the loocation): access via active.clojure.condition/location-condition-line
Location information about an exceptional situation `namespace` (namespace of the location): access via [[active.clojure.condition/location-condition-namespace]] `file` (file name of the location): access via [[active.clojure.condition/location-condition-file]] `line` (line number of the loocation): access via [[active.clojure.condition/location-condition-line]]
Human-reaable message.
message
(message text): access via active.clojure.condition/condition-message
Human-reaable message. `message` (message text): access via [[active.clojure.condition/condition-message]]
Serious condition that should not be ignored.
Serious condition that should not be ignored.
Throwable value that's not a condition.
value
(Throwable object): access via active.clojure.condition/throwable-value
Throwable value that's not a condition. `value` (Throwable object): access via [[active.clojure.condition/throwable-value]]
Information about in what entity an exceptional situation occurred.
who
(name of the entity): access via active.clojure.condition/condition-who
Information about in what entity an exceptional situation occurred. `who` (name of the entity): access via [[active.clojure.condition/condition-who]]
(->condition thing)
Coerce something into a condition object.
This yields thing
if it's already a condition,
and an [[&exception]] condition if it's not.
Coerce something into a condition object. This yields `thing` if it's already a condition, and an [[&exception]] condition if it's not.
(assert x)
(assert x message)
Evaluates expr and throws an exception if it does not evaluate to logical true.
Evaluates expr and throws an exception if it does not evaluate to logical true.
(assertion-violation who message & irritants)
Throw an exception that signals that an assertion was violated.
This should be called when an invalid call to a procedure was made, either passing an invalid number of arguments, or passing an argument that it is not specified to handle.
The irritants
arguments can be conditions, in which case they're included
in the resulting condition, or non-conditions, which are included in an
&irritants
condition.
On Java, irritants
can also include Throwable
objects.
Throw an exception that signals that an assertion was violated. This should be called when an invalid call to a procedure was made, either passing an invalid number of arguments, or passing an argument that it is not specified to handle. The `irritants` arguments can be conditions, in which case they're included in the resulting condition, or non-conditions, which are included in an [[&irritants]] condition. On Java, `irritants` can also include ``Throwable`` objects.
(assertion-violation? thing)
Is object a active.clojure.condition/&assertion
condition?
Is object a [[active.clojure.condition/&assertion]] condition?
(combine-conditions & component-conditions)
Make a compound condition from constituents.
nil
and false
arguments are ignored.
Make a compound condition from constituents. `nil` and `false` arguments are ignored.
(condition-accessor type field-name)
Create an an accessor for field-name
for conditions of type type
.
Create an an accessor for `field-name` for conditions of type `type`.
(condition-irritants &irritants)
Access the irritants
(objects providing more information) field from a active.clojure.condition/&irritants
condition.
Access the `irritants` (objects providing more information) field from a [[active.clojure.condition/&irritants]] condition.
Access the irritants
(objects providing more information) field from a [[user/&irritants]] condition.
Access the `irritants` (objects providing more information) field from a [[user/&irritants]] condition.
(condition-message &message)
Access the message
(message text) field from a active.clojure.condition/&message
condition.
Access the `message` (message text) field from a [[active.clojure.condition/&message]] condition.
Access the message
(message text) field from a [[user/&message]] condition.
Access the `message` (message text) field from a [[user/&message]] condition.
(condition-of-type? type cond)
Does condition cond
have type type
?
Does condition `cond` have type `type`?
(condition-predicate type)
Make predicate from condition type.
Make predicate from condition type.
(condition-who &who)
Access the who
(name of the entity) field from a active.clojure.condition/&who
condition.
Access the `who` (name of the entity) field from a [[active.clojure.condition/&who]] condition.
Access the who
(name of the entity) field from a [[user/&who]] condition.
Access the `who` (name of the entity) field from a [[user/&who]] condition.
(decode-condition con)
Return a keyword describing the type, a symbol or string describing the source of the problem, an error message or nil, and a sequence of other objects describing the problem.
Valid type symbols include: :error
, :assertion-violation
,
:violation
, :serious
.
Return a keyword describing the type, a symbol or string describing the source of the problem, an error message or nil, and a sequence of other objects describing the problem. Valid type symbols include: `:error`, `:assertion-violation`, `:violation`, `:serious`.
(define-condition-type ?condition-type
?supertype
?constructor
?predicate
&
?field-specs)
(define-condition-type <condition-type>
<supertype>
<constructor> <predicate>
[<field> <accessor> ...)
<Condition-type>
, <supertype>
, <constructor>
, and
<predicate>
must all be identifiers. Each <field>
and <accessor>
must be identifiers.
The define-condition-type
form defines a condition type named
<condition-type>
. It will have <supertype> has its parent type. The
remaining identifiers will be bound as follows:
<Constructor>
is bound to a constructor for the type: It accepts
one argument for each of the condition type's complete set of fields
(including parent types, with the fields of the parent coming before
those of the extension in the arguments) and returns a condition
object initialized to those arguments.
<Predicate>
is bound to a predicate that identifies conditions of
type <condition-type>
or any of its subtypes.
Each <accessor>
is bound to a function that extracts the
corresponding field from a condition of type <condition-type>
.
:doc
properties attached to the metadata of <condition-type>
and
`the <field>s will yield proper docstrings for the names defined by this form.
(define-condition-type <condition-type> <supertype> <constructor> <predicate> [<field> <accessor> ...) `<Condition-type>`, `<supertype>`, `<constructor>`, and `<predicate>` must all be identifiers. Each `<field>` and `<accessor>` must be identifiers. The `define-condition-type` form defines a condition type named `<condition-type>`. It will have <supertype> has its parent type. The remaining identifiers will be bound as follows: `<Constructor>` is bound to a constructor for the type: It accepts one argument for each of the condition type's complete set of fields (including parent types, with the fields of the parent coming before those of the extension in the arguments) and returns a condition object initialized to those arguments. `<Predicate>` is bound to a predicate that identifies conditions of type `<condition-type>` or any of its subtypes. Each `<accessor>` is bound to a function that extracts the corresponding field from a condition of type `<condition-type>`. `:doc` properties attached to the metadata of `<condition-type>` and `the <field>s will yield proper docstrings for the names defined by this form.
(error who message & irritants)
Throw an exception that signals that an error has occurred.
This function should be called when an error has occurred, typically caused by something that has gone wrong in the interaction of the program with the external world or the user.
The irritants
arguments can be conditions, in which case they're included
in the resulting condition, or non-conditions, which are included in an
&irritants
condition.
Throw an exception that signals that an error has occurred. This function should be called when an error has occurred, typically caused by something that has gone wrong in the interaction of the program with the external world or the user. The `irritants` arguments can be conditions, in which case they're included in the resulting condition, or non-conditions, which are included in an [[&irritants]] condition.
(error? thing)
Is object a active.clojure.condition/&error
condition?
Is object a [[active.clojure.condition/&error]] condition?
(irritants-condition? thing)
Is object a active.clojure.condition/&irritants
condition?
Is object a [[active.clojure.condition/&irritants]] condition?
(location-condition-file &location)
Access the file
(file name of the location) field from a active.clojure.condition/&location
condition.
Access the `file` (file name of the location) field from a [[active.clojure.condition/&location]] condition.
Access the file
(file name of the location) field from a [[user/&location]] condition.
Access the `file` (file name of the location) field from a [[user/&location]] condition.
(location-condition-line &location)
Access the line
(line number of the loocation) field from a active.clojure.condition/&location
condition.
Access the `line` (line number of the loocation) field from a [[active.clojure.condition/&location]] condition.
Access the line
(line number of the loocation) field from a [[user/&location]] condition.
Access the `line` (line number of the loocation) field from a [[user/&location]] condition.
(location-condition-namespace &location)
Access the namespace
(namespace of the location) field from a active.clojure.condition/&location
condition.
Access the `namespace` (namespace of the location) field from a [[active.clojure.condition/&location]] condition.
Access the namespace
(namespace of the location) field from a [[user/&location]] condition.
Access the `namespace` (namespace of the location) field from a [[user/&location]] condition.
(location-condition? thing)
Is object a active.clojure.condition/&location
condition?
Is object a [[active.clojure.condition/&location]] condition?
Construct a active.clojure.condition/&assertion
condition.
Construct a [[active.clojure.condition/&assertion]] condition.
(make-condition condition-components)
Make a condition from components.
For internal use only.
Make a condition from components. For internal use only.
Construct a active.clojure.condition/&error
condition.
Construct a [[active.clojure.condition/&error]] condition.
Construct a active.clojure.condition/&irritants
condition.
Construct a [[active.clojure.condition/&irritants]] condition.
Construct a active.clojure.condition/&location
condition.
Construct a [[active.clojure.condition/&location]] condition.
Construct a active.clojure.condition/&message
condition.
Construct a [[active.clojure.condition/&message]] condition.
Construct a active.clojure.condition/&serious
condition.
Construct a [[active.clojure.condition/&serious]] condition.
Construct a active.clojure.condition/&throwable
condition.
Construct a [[active.clojure.condition/&throwable]] condition.
Construct a active.clojure.condition/&violation
condition.
Construct a [[active.clojure.condition/&violation]] condition.
Construct a active.clojure.condition/&warning
condition.
Construct a [[active.clojure.condition/&warning]] condition.
Construct a active.clojure.condition/&who
condition.
Construct a [[active.clojure.condition/&who]] condition.
(message-condition? thing)
Is object a active.clojure.condition/&message
condition?
Is object a [[active.clojure.condition/&message]] condition?
(serious-condition? thing)
Is object a active.clojure.condition/&serious
condition?
Is object a [[active.clojure.condition/&serious]] condition?
(stack-trace-who st)
Get a suitable argument for &who
from an exception object.
Get a suitable argument for [[&who]] from an exception object.
(throw-condition ?base ?who ?message ?irritants)
Throw a condition.
For internal use.
Throw a condition. For internal use.
(throwable-value &throwable)
Access the value
(Throwable object) field from a active.clojure.condition/&throwable
condition.
Access the `value` (Throwable object) field from a [[active.clojure.condition/&throwable]] condition.
Access the value
(Throwable object) field from a [[user/&throwable]] condition.
Access the `value` (Throwable object) field from a [[user/&throwable]] condition.
(throwable? thing)
Is object a active.clojure.condition/&throwable
condition?
Is object a [[active.clojure.condition/&throwable]] condition?
(violation? thing)
Is object a active.clojure.condition/&violation
condition?
Is object a [[active.clojure.condition/&violation]] condition?
(warning? thing)
Is object a active.clojure.condition/&warning
condition?
Is object a [[active.clojure.condition/&warning]] condition?
(who-condition? thing)
Is object a active.clojure.condition/&who
condition?
Is object a [[active.clojure.condition/&who]] condition?
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close