condition-utils
SRFI 12 Condition Utilities
- condition-utils
- Documentation
- Argument Conventions
- Condition Library
- EXN Condition Library
- Standard Condition Library
- Usage
- Condition Predicates
- arity-condition?
- type-condition?
- arithmetic-condition?
- i/o-condition?
- file-condition?
- network-condition?
- network-timeout-condition?
- bounds-condition?
- runtime-condition?
- runtime-limit-condition?
- runtime-cycle-condition?
- match-condition?
- syntax-condition?
- process-condition?
- access-condition?
- domain-condition?
- memory-condition?
- HTTP Client Condition Library
- Intarweb Condition Library
- Usage
- Condition Predicates
- http-condition?
- urlencoded-request-data-limit-exceeded?
- line-limit-exceeded?
- header-error?
- header-limit-exceeded?
- unknown-protocol-line?
- unknown-protocol?
- unknown-code?
- unknown-status?
- rfc1123-subparser?
- rfc850-subparser?
- asctime-subparser?
- http-date-subparser?
- unencoded-header?
- username-with-colon?
- Condition Property Accessors
- urlencoded-request-data-limit-exceeded-contents
- urlencoded-request-data-limit-exceeded-limit
- line-limit-exceeded-contents
- line-limit-exceeded-limit
- header-error-contents
- header-limit-exceeded-contents
- header-limit-exceeded-limit
- unknown-protocol-line-line
- unknown-protocol-major
- unknown-protocol-minor
- unknown-code-code
- unknown-status-status
- rfc1123-subparser-value?
- rfc850-subparser-value?
- asctime-subparser-value?
- http-date-subparser-value?
- unencoded-header-value?
- username-with-colon-value?
- Condition Libraries w/ Runtime Lookup
- Bugs & Limitations
- Notes
- Author
- Repository
- Version history
- License
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.
KIND is usually a symbol but not #f.
PROP is usually a symbol but not #f.
CONDITION-SPEC is a:
- CONDITION
- a condition object
- atom
- (make-property-condition <atom>) ;see KIND
- list
- (apply make-property-condition <list>) ;(KIND PROP VALUE ...)
Condition Library
Usage
(import condition-utils)
make-condition+
[procedure] (make-condition+ CONDITION-SPEC...) -> property-conditionReturns a composite-condition CONDITION-SPEC....
make-condition-predicate
[syntax] (make-condition-predicate KIND...) -> (procedure (*) boolean)Returns a condition-predicate for KIND....
- KIND
- symbol ;argument is quoted!
condition-predicate*
[procedure] (condition-predicate* KIND) -> (* -> boolean : condition)Returns a "memoized" condition-predicate for KIND.
- KIND
- (not false) ;argument is evaluated
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.
- KIND
- symbol ;argument is quoted!
- PROP
- symbol ;argument is quoted!
condition-property-accessor*
[procedure] (condition-property-accessor* KIND PROP [DEFAULT #f]) -> (condition -> *)Returns a "memoized" condition-property-accessor for KIND.
- KIND
- (not false) ;argument is evaluated
- PROP
- (not false) ;argument is evaluated
condition-irritants
[procedure] (condition-irritants CONDITION) -> listReturns 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.
- CHICKEN 4
- alist
- CHICKEN 5
- plist
The properties are without associated condition information.
write-condition
[procedure] (write-condition CONDITION [PORT (current-output-port) [HEADER "Error"]])Produces on PORT the form:
Error: <condition-kind>: <condition-property> ...
+: <condition-kind>: <condition-property> ... ... for a composite condition ...
EXN Condition Library
Usage
(import exn-condition)
make-exn-condition
[procedure] (make-exn-condition [LOC [MSG [ARGS [CALL-CHAIN [ERRNO]]]]]) -> property-conditionReturns an exn property-condition with optional location, arguments, call-chain, and errno property values.
Defaults:
- LOC
- missing
- MSG
- "unknown"
- ARGS
- missing
- CALL-CHAIN
- missing
- ERRNO
- missing
Will always include message property in the property-condition.
make-exn-condition*
[procedure] (make-exn-condition* [location:] [message:] [arguments:] [call-chain:] [errno:]) -> property-conditionReturns an exn property-condition with optional location, arguments, call-chain, and errno property values.
Defaults:
- location
- missing
- message
- "unknown"
- arguments
- missing
- call-chain:
- missing
- errno
- missing
Will always include message property in the property-condition.
make-exn-condition+
[procedure] (make-exn-condition+ LOC MSG ARGS [CALL-CHAIN] [ERRNO] [CONDITION-SPEC...]) -> property-conditionReturns 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 & ERRNO arguments are detected by type & structure.
When MSG is #f the value "unknown" is used.
write-exn-condition
[procedure] (write-exn-condition CONDITION [PORT (current-output-port) [HEADER "Error" [CHAIN-HEADER "\n\tCall history:\n"]]])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.
exn-condition?
[procedure] (exn-condition? CONDITION) -> booleanexn-location
[procedure] (exn-location CONDITION) -> *exn-message
[procedure] (exn-message CONDITION) -> *exn-arguments
[procedure] (exn-arguments CONDITION) -> *exn-call-chain
[procedure] (exn-call-chain CONDITION) -> *exn-errno
[procedure] (exn-errno CONDITION) -> *Standard Condition Library
Usage
(import standard-conditions)
Condition Predicates
arity-condition?
[procedure] (arity-condition? CONDITION) -> booleantype-condition?
[procedure] (type-condition? CONDITION) -> booleanarithmetic-condition?
[procedure] (arithmetic-condition? CONDITION) -> booleani/o-condition?
[procedure] (i/o-condition? CONDITION) -> booleanfile-condition?
[procedure] (file-condition? CONDITION) -> booleannetwork-condition?
[procedure] (network-condition? CONDITION) -> booleannetwork-timeout-condition?
[procedure] (network-timeout-condition? CONDITION) -> booleanbounds-condition?
[procedure] (bounds-condition? CONDITION) -> booleanruntime-condition?
[procedure] (runtime-condition? CONDITION) -> booleanruntime-limit-condition?
[procedure] (runtime-limit-condition? CONDITION) -> booleanruntime-cycle-condition?
[procedure] (runtime-cycle-condition? CONDITION) -> booleanmatch-condition?
[procedure] (match-condition? CONDITION) -> booleansyntax-condition?
[procedure] (syntax-condition? CONDITION) -> booleanprocess-condition?
[procedure] (process-condition? CONDITION) -> booleanaccess-condition?
[procedure] (access-condition? CONDITION) -> booleandomain-condition?
[procedure] (domain-condition? CONDITION) -> booleanmemory-condition?
[procedure] (memory-condition? CONDITION) -> booleanHTTP Client Condition Library
Usage
(import http-client-conditions)
Condition Predicates
http-condition?
[procedure] (http-condition? CONDITION) -> booleanclient-error-condition?
[procedure] (client-error-condition? CONDITION) -> booleanserver-error-condition?
[procedure] (server-error-condition? CONDITION) -> booleanunexpected-server-response-condition?
[procedure] (unexpected-server-response-condition? CONDITION) -> booleanredirect-depth-exceeded-condition?
[procedure] (redirect-depth-exceeded-condition? CONDITION) -> booleanunsupported-uri-scheme-condition?
[procedure] (unsupported-uri-scheme-condition? CONDITION) -> booleanunknown-authtype-condition?
[procedure] (unknown-authtype-condition? CONDITION) -> booleanCondition Property Accessors
client-error-response
[procedure] (client-error-response CONDITION) -> *client-error-body
[procedure] (client-error-body CONDITION) -> *server-error-response
[procedure] (server-error-response CONDITION) -> *server-error-body
[procedure] (server-error-body CONDITION) -> *unexpected-server-response-response
[procedure] (unexpected-server-response-response CONDITION) -> *unexpected-server-response-body
[procedure] (unexpected-server-response-body CONDITION) -> *redirect-depth-exceeded-uri
[procedure] (redirect-depth-exceeded-uri CONDITION) -> *formdata-error-condition?
[procedure] (formdata-error-condition? CONDITION) -> booleanunsupported-uri-scheme-uri-scheme
[procedure] (unsupported-uri-scheme-uri-scheme CONDITION) -> *unsupported-uri-scheme-request-uri
[procedure] (unsupported-uri-scheme-request-uri CONDITION) -> *unknown-authtype-authtype
[procedure] (unknown-authtype-authtype CONDITION) -> *Intarweb Condition Library
Usage
(import intarweb-conditions)
Condition Predicates
http-condition?
[procedure] (http-condition? CONDITION) -> booleanurlencoded-request-data-limit-exceeded?
[procedure] (urlencoded-request-data-limit-exceeded? CONDITION) -> booleanline-limit-exceeded?
[procedure] (line-limit-exceeded? CONDITION) -> booleanheader-error?
[procedure] (header-error? CONDITION) -> booleanheader-limit-exceeded?
[procedure] (header-limit-exceeded? CONDITION) -> booleanunknown-protocol-line?
[procedure] (unknown-protocol-line? CONDITION) -> booleanunknown-protocol?
[procedure] (unknown-protocol? CONDITION) -> booleanunknown-code?
[procedure] (unknown-code? CONDITION) -> booleanunknown-status?
[procedure] (unknown-status? CONDITION) -> booleanrfc1123-subparser?
[procedure] (rfc1123-subparser? CONDITION) -> booleanrfc850-subparser?
[procedure] (rfc850-subparser? CONDITION) -> booleanasctime-subparser?
[procedure] (asctime-subparser? CONDITION) -> booleanhttp-date-subparser?
[procedure] (http-date-subparser? CONDITION) -> booleanunencoded-header?
[procedure] (unencoded-header? CONDITION) -> booleanusername-with-colon?
[procedure] (username-with-colon? CONDITION) -> booleanCondition Property Accessors
urlencoded-request-data-limit-exceeded-contents
[procedure] (urlencoded-request-data-limit-exceeded-contents CONDITION) -> *urlencoded-request-data-limit-exceeded-limit
[procedure] (urlencoded-request-data-limit-exceeded-limit CONDITION) -> *line-limit-exceeded-contents
[procedure] (line-limit-exceeded-contents CONDITION) -> *line-limit-exceeded-limit
[procedure] (line-limit-exceeded-limit CONDITION) -> *header-error-contents
[procedure] (header-error-contents CONDITION) -> *header-limit-exceeded-contents
[procedure] (header-limit-exceeded-contents CONDITION) -> *header-limit-exceeded-limit
[procedure] (header-limit-exceeded-limit CONDITION) -> *unknown-protocol-line-line
[procedure] (unknown-protocol-line-line CONDITION) -> *unknown-protocol-major
[procedure] (unknown-protocol-major CONDITION) -> *unknown-protocol-minor
[procedure] (unknown-protocol-minor CONDITION) -> *unknown-code-code
[procedure] (unknown-code-code CONDITION) -> *unknown-status-status
[procedure] (unknown-status-status CONDITION) -> *rfc1123-subparser-value?
[procedure] (rfc1123-subparser-value? CONDITION) -> booleanrfc850-subparser-value?
[procedure] (rfc850-subparser-value? CONDITION) -> booleanasctime-subparser-value?
[procedure] (asctime-subparser-value? CONDITION) -> booleanhttp-date-subparser-value?
[procedure] (http-date-subparser-value? CONDITION) -> booleanunencoded-header-value?
[procedure] (unencoded-header-value? CONDITION) -> booleanusername-with-colon-value?
[procedure] (username-with-colon-value? CONDITION) -> booleanCondition Libraries w/ Runtime Lookup
Usage Example
(import (rename (standard-conditions memo) (get standard-conditions-get))) (import (rename (intarweb-conditions memo) (get intarweb-conditions-get))) (import (rename (http-client-conditions memo) (get http-client-conditions-get))) (define unexpected-server-response-response (http-client-conditions-get 'unexpected-server-response-response)
Bugs & Limitations
- SRFI 12 accepts any object as a condition kind or property tag, even #f. This extension restricts such to (not #f)!
Notes
- write-exn-condition is from write-exception of https://github.com/dleslie/geiser/blob/master/scheme/chicken/geiser/emacs.scm.
Author
Repository
This egg is hosted on the CHICKEN Subversion repository:
https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/condition-utils
If you want to check out the source code repository of this egg and you are not familiar with Subversion, see this page.
Version history
- 2.3.1
- Fix condition predicate & accessor caching.
- 2.3.0
- Add errno & make-exn-condition*.
- 2.2.2
- .
- 2.2.1
- .
- 2.2.0
- Add condition library runtime lookup get API.
- 2.1.4
- .
- 2.1.3
- .
- 2.1.2
- .
- 2.1.1
- .
- 2.1.0
- CHICKEN 5 release.
- 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-2024 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.