;;;; standard-conditions.scm ;;;; Kon Lovett, Jun '13 (module standard-conditions (;export ; exn-condition? exn-location exn-message exn-arguments exn-call-chain ; 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? ) (import scheme chicken) (use condition-utils) ;;; Builtin Conditions ; Signaled on errors. (define exn-condition? (condition-predicate* 'exn)) (define exn-location (make-condition-property-accessor exn location)) (define exn-message (make-condition-property-accessor exn message)) (define exn-arguments (make-condition-property-accessor exn arguments)) (define exn-call-chain (make-condition-property-accessor exn call-chain)) ; Signaled when a procedure is called with the wrong number of arguments. (define arity-condition? (make-condition-predicate exn arity)) ; Signaled on type-mismatch errors, for example when an argument of the wrong ; type is passed to a built-in procedure. (define type-condition? (make-condition-predicate exn type)) ; Signaled on arithmetic errors, like division by zero. (define arithmetic-condition? (make-condition-predicate exn arithmetic)) ; Signaled on input/output errors. (define i/o-condition? (make-condition-predicate exn i/o)) ; Signaled on file-related errors. (define file-condition? (make-condition-predicate exn i/o file)) ; Signaled on network errors. (define network-condition? (make-condition-predicate exn i/o net)) ; Signaled on network timeout errors. (define network-timeout-condition? (make-condition-predicate exn i/o net timeout)) ; Signaled on errors caused by accessing non-existent elements of a collection. (define bounds-condition? (make-condition-predicate exn bounds)) ; Signaled on low-level runtime-system error-situations. (define runtime-condition? (make-condition-predicate exn runtime)) ; Signaled when an internal limit is exceeded (like running out of memory). (define runtime-limit-condition? (make-condition-predicate exn runtime limit)) ; Signaled when a graph cycle detected. (define runtime-cycle-condition? (make-condition-predicate exn runtime cycle)) ; Signaled on errors raised by failed matches (see the section on match). (define match-condition? (make-condition-predicate exn match)) ; Signaled on syntax errors. (define syntax-condition? (make-condition-predicate exn syntax)) ; Signaled on process errors. (define process-condition? (make-condition-predicate exn process)) ; Signaled on access errors. (define access-condition? (make-condition-predicate exn access)) ; Signaled on domain errors. (define domain-condition? (make-condition-predicate exn domain)) ; Signaled on memory errors. (define memory-condition? (make-condition-predicate exn memory)) ) ;standard-conditions