You are looking at historical revision 33613 of this page. It may differ significantly from its current revision.

condition-utils

SRFI 12 Condition Utilities

Documentation

Convenience API for constructing common Chicken exception conditions, predicates, and accessors.

Argument Conventions

LOC is a symbol, or #f.

MSG is a string, or #f.

ARGS is a list, or #f.

CHN is the result of (get-call-chain), or #f.

COND is a:

property-condition
literal
symbol
(make-property-condition <symbol>)
list
(apply make-property-condition <list>)

KIND is a symbol.

PROP is a symbol.

make-exn-condition

[procedure] (make-exn-condition [LOC [MSG [ARGS [CHN]]]]) => property-condition

Returns an exn property-condition with optional location, arguments, and call-chain property values.

Defaults:

LOC
missing
MSG
"unknown"
ARGS
missing
CHN
missing

Will always include message property in the property-condition.

make-exn-condition+

[procedure] (make-exn-condition+ LOC MSG ARGS [CHN] [COND...]) => property-condition

Returns a composite-condition exn COND....

When one-of LOC, MSG, or ARGS is without a useful value in the error context use #f as the actual argument. The optional CHN argument is detected by structure.

When MSG is #f the value "unknown" is used.

make-condition+

[procedure] (make-condition+ COND...) => property-condition

Returns a composite-condition COND....

make-condition-predicate

[syntax] (make-condition-predicate KIND...) => (procedure (*) boolean)

Returns a condition-predicate for KIND....

make-condition-property-accessor

[syntax] (make-condition-property-accessor KIND PROP [DEFAULT]) => (procedure (*) boolean)

Returns a condition-property-accessor for KIND PROP. The default value of DEFAULT is #f.

condition-irritants

[procedure] (condition-irritants EXN) => list

Returns a property list of the condition properties for the condition EXN. The properties are without associated condition information.

write-exn-condition

[procedure] (write-exn-condition COND)

Produces on (current-output-port) the form:

Error: (<location - if any>) <message - if any>: <arguments - if any>
Call history:
<call-chain>

or when call-chain unavailable:

Error: (<location - if any>) <message - if any>: <arguments - if any>

condition-predicate*

[procedure] (condition-predicate* KIND) => (procedure (*) boolean)

Returns a "memoized" condition-predicate for KIND.

condition-property-accessor*

[procedure] (condition-property-accessor* KIND PROP [DEFAULT]) => (procedure (*) boolean)

Returns a "memoized" condition-property-accessor for KIND. The default value of DEFAULT is #f.

Usage

(require-extension condition-utils)

Bugs & Limitations

Notes

Author

Kon Lovett

Version history

1.1.1
added write-exn-condition
1.1.0
added make-exn-condition
1.0.4
default exn msg
1.0.3
added call-chain argument & standard conditions
1.0.2
Fix for ticket #630
1.0.1
1.0.0
Hello (from "check-errors:1.11.0")

License

Copyright (C) 2009-2015 Kon Lovett. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.