chickadee » condition-utils

Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

condition-utils

SRFI 12 Condition Utilities

TOC »

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.

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

CONDITION is a property-condition.

CONDITION-SPEC is a:

CONDITION
a condition object
symbol
(make-property-condition <symbol>)
list
(apply make-property-condition <list>)

KIND is a symbol.

PROP is a symbol.

Usage

(require-extension condition-utils)

make-exn-condition

make-exn-condition #!optional LOC MSG ARGS CALL-CHAINprocedure

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

Defaults:

LOC
missing
MSG
"unknown"
ARGS
missing
CALL-CHAIN
missing

Will always include message property in the property-condition.

make-exn-condition+

(make-exn-condition+ LOC MSG ARGS [CALL-CHAIN] [CONDITION-SPEC...]) --> property-conditionprocedure

Returns a composite-condition exn CONDITION-SPEC....

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

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

make-condition+

make-condition+ CONDITION-SPEC...procedure

Returns a composite-condition CONDITION-SPEC....

make-condition-predicate

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

Returns a condition-predicate for KIND....

make-condition-property-accessor

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

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

condition-irritants

condition-irritants CONDITIONprocedure

Returns a list of the condition properties for the condition CONDITION. The form of the list, alist vs. plist, is dependent on the result of the system procedure condition->list.

The properties are without associated condition information.

write-exn-condition

(write-exn-condition CONDITION [PORT (current-output-port) [HEADER "Error" [CHAIN-HEADER "\n\tCall history:\n"]]])procedure

Produces on PORT the form:

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

   +: <condition-kind>: <condition-property> ...
      ... for a composite condition ...
      Call history:
      <call-chain>

The call-chain may not be available.

write-condition

(write-condition CONDITION [PORT (current-output-port) [HEADER "Error"]])procedure

Produces on PORT the form:

Error: <condition-kind>: <condition-property> ...

   +: <condition-kind>: <condition-property> ...
      ... for a composite condition ...

condition-predicate*

condition-predicate* KINDprocedure

Returns a "memoized" condition-predicate for KIND.

condition-property-accessor*

(condition-property-accessor* KIND PROP [DEFAULT #f]) --> (condition --> *)procedure

Returns a "memoized" condition-property-accessor for KIND.

Standard Condition Library

Usage

(require-extension standard-conditions)

Condition Predicates

exn-condition?
exn-condition? CONDITIONprocedure
arity-condition?
arity-condition? CONDITIONprocedure
type-condition?
type-condition? CONDITIONprocedure
arithmetic-condition?
arithmetic-condition? CONDITIONprocedure
i/o-condition?
i/o-condition? CONDITIONprocedure
file-condition?
file-condition? CONDITIONprocedure
network-condition?
network-condition? CONDITIONprocedure
network-timeout-condition?
network-timeout-condition? CONDITIONprocedure
bounds-condition?
bounds-condition? CONDITIONprocedure
runtime-condition?
runtime-condition? CONDITIONprocedure
runtime-limit-condition?
runtime-limit-condition? CONDITIONprocedure
runtime-cycle-condition?
runtime-cycle-condition? CONDITIONprocedure
match-condition?
match-condition? CONDITIONprocedure
syntax-condition?
syntax-condition? CONDITIONprocedure
process-condition?
process-condition? CONDITIONprocedure
access-condition?
access-condition? CONDITIONprocedure
domain-condition?
domain-condition? CONDITIONprocedure
memory-condition?
memory-condition? CONDITIONprocedure

Condition Property Accessors

exn-location
exn-location CONDITIONprocedure
exn-message
exn-message CONDITIONprocedure
exn-arguments
exn-arguments CONDITIONprocedure
exn-call-chain
exn-call-chain CONDITIONprocedure

HTTP Client Condition Library

Usage

(require-extension http-client-conditions)

Condition Predicates

http-condition?
http-condition? CONDITIONprocedure
client-error-condition?
client-error-condition? CONDITIONprocedure
server-error-condition?
server-error-condition? CONDITIONprocedure
unexpected-server-response-condition?
unexpected-server-response-condition? CONDITIONprocedure
redirect-depth-exceeded-condition?
redirect-depth-exceeded-condition? CONDITIONprocedure
unsupported-uri-scheme-condition?
unsupported-uri-scheme-condition? CONDITIONprocedure
unknown-authtype-condition?
unknown-authtype-condition? CONDITIONprocedure

Condition Property Accessors

client-error-response
client-error-response CONDITIONprocedure
client-error-body
client-error-body CONDITIONprocedure
server-error-response
server-error-response CONDITIONprocedure
server-error-body
server-error-body CONDITIONprocedure
unexpected-server-response-response
unexpected-server-response-response CONDITIONprocedure
unexpected-server-response-body
unexpected-server-response-body CONDITIONprocedure
redirect-depth-exceeded-uri
redirect-depth-exceeded-uri CONDITIONprocedure
formdata-error-condition?
formdata-error-condition? CONDITIONprocedure
unsupported-uri-scheme-uri-scheme
unsupported-uri-scheme-uri-scheme CONDITIONprocedure
unsupported-uri-scheme-request-uri
unsupported-uri-scheme-request-uri CONDITIONprocedure
unknown-authtype-authtype
unknown-authtype-authtype CONDITIONprocedure

Intarweb Condition Library

Usage

(require-extension intarweb-conditions)

Condition Predicates

http-condition?
http-condition? CONDITIONprocedure
urlencoded-request-data-limit-exceeded?
urlencoded-request-data-limit-exceeded? CONDITIONprocedure
line-limit-exceeded?
line-limit-exceeded? CONDITIONprocedure
header-error?
header-error? CONDITIONprocedure
header-limit-exceeded?
header-limit-exceeded? CONDITIONprocedure
unknown-protocol-line?
unknown-protocol-line? CONDITIONprocedure
unknown-protocol?
unknown-protocol? CONDITIONprocedure
unknown-code?
unknown-code? CONDITIONprocedure
unknown-status?
unknown-status? CONDITIONprocedure
rfc1123-subparser?
rfc1123-subparser? CONDITIONprocedure
rfc850-subparser?
rfc850-subparser? CONDITIONprocedure
asctime-subparser?
asctime-subparser? CONDITIONprocedure
http-date-subparser?
http-date-subparser? CONDITIONprocedure
unencoded-header?
unencoded-header? CONDITIONprocedure
username-with-colon?
username-with-colon? CONDITIONprocedure

Condition Property Accessors

urlencoded-request-data-limit-exceeded-contents
urlencoded-request-data-limit-exceeded-contents CONDITIONprocedure
urlencoded-request-data-limit-exceeded-limit
urlencoded-request-data-limit-exceeded-limit CONDITIONprocedure
line-limit-exceeded-contents
line-limit-exceeded-contents CONDITIONprocedure
line-limit-exceeded-limit
line-limit-exceeded-limit CONDITIONprocedure
header-error-contents
header-error-contents CONDITIONprocedure
header-limit-exceeded-contents
header-limit-exceeded-contents CONDITIONprocedure
header-limit-exceeded-limit
header-limit-exceeded-limit CONDITIONprocedure
unknown-protocol-line-line
unknown-protocol-line-line CONDITIONprocedure
unknown-protocol-major
unknown-protocol-major CONDITIONprocedure
unknown-protocol-minor
unknown-protocol-minor CONDITIONprocedure
unknown-code-code
unknown-code-code CONDITIONprocedure
unknown-status-status
unknown-status-status CONDITIONprocedure
rfc1123-subparser-value?
rfc1123-subparser-value? CONDITIONprocedure
rfc850-subparser-value?
rfc850-subparser-value? CONDITIONprocedure
asctime-subparser-value?
asctime-subparser-value? CONDITIONprocedure
http-date-subparser-value?
http-date-subparser-value? CONDITIONprocedure
unencoded-header-value?
unencoded-header-value? CONDITIONprocedure
username-with-colon-value?
username-with-colon-value? CONDITIONprocedure

Bugs & Limitations

Notes

Author

Kon Lovett

Version history

1.5.1
Fix for empty call-chain.
1.5.0
Add types.
1.4.2
Fix #1378
1.4.1
Fix write-exn-condition call-chain header duplication.
1.4.0
Add HEADER to write-exn-condition & write-condition. Add CHAIN-HEADER to write-exn-condition. Follow error form more closely.
1.3.0
write-exn-condition now includes all elements of a composite-condition. Added write-condition.
1.2.0
amended write-exn-condition, add doc for condition libraries.
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-2017 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.

Contents »