condition-utils

SRFI 12 Condition Utilities

  1. condition-utils
  2. Documentation
    1. Argument Conventions
    2. Usage
    3. make-exn-condition
    4. make-exn-condition+
    5. make-condition+
    6. make-condition-predicate
    7. make-condition-property-accessor
    8. condition-irritants
    9. write-exn-condition
    10. write-condition
    11. condition-predicate*
    12. condition-property-accessor*
    13. Standard Condition Library
      1. Usage
      2. Condition Predicates
        1. exn-condition?
        2. arity-condition?
        3. type-condition?
        4. arithmetic-condition?
        5. i/o-condition?
        6. file-condition?
        7. network-condition?
        8. network-timeout-condition?
        9. bounds-condition?
        10. runtime-condition?
        11. runtime-limit-condition?
        12. runtime-cycle-condition?
        13. match-condition?
        14. syntax-condition?
        15. process-condition?
        16. access-condition?
        17. domain-condition?
        18. memory-condition?
      3. Condition Property Accessors
        1. exn-location
        2. exn-message
        3. exn-arguments
        4. exn-call-chain
    14. HTTP Client Condition Library
      1. Usage
      2. Condition Predicates
        1. http-condition?
        2. client-error-condition?
        3. server-error-condition?
        4. unexpected-server-response-condition?
        5. redirect-depth-exceeded-condition?
        6. unsupported-uri-scheme-condition?
        7. unknown-authtype-condition?
      3. Condition Property Accessors
        1. client-error-response
        2. client-error-body
        3. server-error-response
        4. server-error-body
        5. unexpected-server-response-response
        6. unexpected-server-response-body
        7. redirect-depth-exceeded-uri
        8. formdata-error-condition?
        9. unsupported-uri-scheme-uri-scheme
        10. unsupported-uri-scheme-request-uri
        11. unknown-authtype-authtype
    15. Intarweb Condition Library
      1. Usage
      2. Condition Predicates
        1. http-condition?
        2. urlencoded-request-data-limit-exceeded?
        3. line-limit-exceeded?
        4. header-error?
        5. header-limit-exceeded?
        6. unknown-protocol-line?
        7. unknown-protocol?
        8. unknown-code?
        9. unknown-status?
        10. rfc1123-subparser?
        11. rfc850-subparser?
        12. asctime-subparser?
        13. http-date-subparser?
        14. unencoded-header?
        15. username-with-colon?
      3. Condition Property Accessors
        1. urlencoded-request-data-limit-exceeded-contents
        2. urlencoded-request-data-limit-exceeded-limit
        3. line-limit-exceeded-contents
        4. line-limit-exceeded-limit
        5. header-error-contents
        6. header-limit-exceeded-contents
        7. header-limit-exceeded-limit
        8. unknown-protocol-line-line
        9. unknown-protocol-major
        10. unknown-protocol-minor
        11. unknown-code-code
        12. unknown-status-status
        13. rfc1123-subparser-value?
        14. rfc850-subparser-value?
        15. asctime-subparser-value?
        16. http-date-subparser-value?
        17. unencoded-header-value?
        18. username-with-colon-value?
  3. Bugs & Limitations
  4. Notes
  5. Author
  6. Version history
  7. 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.

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

COND is a property-condition.

COND-EXPR is a:

COND
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

[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-EXPR...]) => property-condition

Returns a composite-condition exn COND-EXPR....

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-EXPR...) => property-condition

Returns a composite-condition COND-EXPR....

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 COND) => list

Returns a list of the condition properties for the condition COND. 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

[procedure] (write-exn-condition COND [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.

write-condition

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

Produces on PORT the form:

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

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

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.

Standard Condition Library

Usage

(require-extension standard-conditions)

Condition Predicates

exn-condition?
[procedure] (exn-condition? COND) => boolean
arity-condition?
[procedure] (arity-condition? COND) => boolean
type-condition?
[procedure] (type-condition? COND) => boolean
arithmetic-condition?
[procedure] (arithmetic-condition? COND) => boolean
i/o-condition?
[procedure] (i/o-condition? COND) => boolean
file-condition?
[procedure] (file-condition? COND) => boolean
network-condition?
[procedure] (network-condition? COND) => boolean
network-timeout-condition?
[procedure] (network-timeout-condition? COND) => boolean
bounds-condition?
[procedure] (bounds-condition? COND) => boolean
runtime-condition?
[procedure] (runtime-condition? COND) => boolean
runtime-limit-condition?
[procedure] (runtime-limit-condition? COND) => boolean
runtime-cycle-condition?
[procedure] (runtime-cycle-condition? COND) => boolean
match-condition?
[procedure] (match-condition? COND) => boolean
syntax-condition?
[procedure] (syntax-condition? COND) => boolean
process-condition?
[procedure] (process-condition? COND) => boolean
access-condition?
[procedure] (access-condition? COND) => boolean
domain-condition?
[procedure] (domain-condition? COND) => boolean
memory-condition?
[procedure] (memory-condition? COND) => boolean

Condition Property Accessors

exn-location
[procedure] (exn-location COND) => *
exn-message
[procedure] (exn-message COND) => *
exn-arguments
[procedure] (exn-arguments COND) => *
exn-call-chain
[procedure] (exn-call-chain COND) => *

HTTP Client Condition Library

Usage

(require-extension http-client-conditions)

Condition Predicates

http-condition?
[procedure] (http-condition? COND) => boolean
client-error-condition?
[procedure] (client-error-condition? COND) => boolean
server-error-condition?
[procedure] (server-error-condition? COND) => boolean
unexpected-server-response-condition?
[procedure] (unexpected-server-response-condition? COND) => boolean
redirect-depth-exceeded-condition?
[procedure] (redirect-depth-exceeded-condition? COND) => boolean
unsupported-uri-scheme-condition?
[procedure] (unsupported-uri-scheme-condition? COND) => boolean
unknown-authtype-condition?
[procedure] (unknown-authtype-condition? COND) => boolean

Condition Property Accessors

client-error-response
[procedure] (client-error-response COND) => *
client-error-body
[procedure] (client-error-body COND) => *
server-error-response
[procedure] (server-error-response COND) => *
server-error-body
[procedure] (server-error-body COND) => *
unexpected-server-response-response
[procedure] (unexpected-server-response-response COND) => *
unexpected-server-response-body
[procedure] (unexpected-server-response-body COND) => *
redirect-depth-exceeded-uri
[procedure] (redirect-depth-exceeded-uri COND) => *
formdata-error-condition?
[procedure] (formdata-error-condition? COND) => boolean
unsupported-uri-scheme-uri-scheme
[procedure] (unsupported-uri-scheme-uri-scheme COND) => *
unsupported-uri-scheme-request-uri
[procedure] (unsupported-uri-scheme-request-uri COND) => *
unknown-authtype-authtype
[procedure] (unknown-authtype-authtype COND) => *

Intarweb Condition Library

Usage

(require-extension intarweb-conditions)

Condition Predicates

http-condition?
[procedure] (http-condition? COND) => boolean
urlencoded-request-data-limit-exceeded?
[procedure] (urlencoded-request-data-limit-exceeded? COND) => boolean
line-limit-exceeded?
[procedure] (line-limit-exceeded? COND) => boolean
header-error?
[procedure] (header-error? COND) => boolean
header-limit-exceeded?
[procedure] (header-limit-exceeded? COND) => boolean
unknown-protocol-line?
[procedure] (unknown-protocol-line? COND) => boolean
unknown-protocol?
[procedure] (unknown-protocol? COND) => boolean
unknown-code?
[procedure] (unknown-code? COND) => boolean
unknown-status?
[procedure] (unknown-status? COND) => boolean
rfc1123-subparser?
[procedure] (rfc1123-subparser? COND) => boolean
rfc850-subparser?
[procedure] (rfc850-subparser? COND) => boolean
asctime-subparser?
[procedure] (asctime-subparser? COND) => boolean
http-date-subparser?
[procedure] (http-date-subparser? COND) => boolean
unencoded-header?
[procedure] (unencoded-header? COND) => boolean
username-with-colon?
[procedure] (username-with-colon? COND) => boolean

Condition Property Accessors

urlencoded-request-data-limit-exceeded-contents
[procedure] (urlencoded-request-data-limit-exceeded-contents COND) => *
urlencoded-request-data-limit-exceeded-limit
[procedure] (urlencoded-request-data-limit-exceeded-limit COND) => *
line-limit-exceeded-contents
[procedure] (line-limit-exceeded-contents COND) => *
line-limit-exceeded-limit
[procedure] (line-limit-exceeded-limit COND) => *
header-error-contents
[procedure] (header-error-contents COND) => *
header-limit-exceeded-contents
[procedure] (header-limit-exceeded-contents COND) => *
header-limit-exceeded-limit
[procedure] (header-limit-exceeded-limit COND) => *
unknown-protocol-line-line
[procedure] (unknown-protocol-line-line COND) => *
unknown-protocol-major
[procedure] (unknown-protocol-major COND) => *
unknown-protocol-minor
[procedure] (unknown-protocol-minor COND) => *
unknown-code-code
[procedure] (unknown-code-code COND) => *
unknown-status-status
[procedure] (unknown-status-status COND) => *
rfc1123-subparser-value?
[procedure] (rfc1123-subparser-value? COND) => boolean
rfc850-subparser-value?
[procedure] (rfc850-subparser-value? COND) => boolean
asctime-subparser-value?
[procedure] (asctime-subparser-value? COND) => boolean
http-date-subparser-value?
[procedure] (http-date-subparser-value? COND) => boolean
unencoded-header-value?
[procedure] (unencoded-header-value? COND) => boolean
username-with-colon-value?
[procedure] (username-with-colon-value? COND) => boolean

Bugs & Limitations

Notes

Author

Kon Lovett

Version history

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.