Next: , Previous: , Up: iklib conditions   [Index]


6.12.7 Failed expression conditions

Let’s say we need code like this:

(if (fixnum? obj)
    obj
  (raise-exception))

we might want to raise a condition object holding the failed expression (fixnum? obj); for this we can use &failed-expression as follows:

(if (fixnum? obj)
    obj
  (raise
    (make-assertion-violation)
    (make-message-condition "failed object validation")
    (make-failed-expression-condition '(fixnum? obj))
    (make-irritants (list obj))))
Condition Object Type: &failed-expression

Condition type used to describe a failed expression, for example in a procedure argument validation predicate. It is derived from &condition. It has the following fields:

failed-expression

A symbolic expression representing the source code of the failed expression.

Function: make-failed-expression-condition sexp

Build and return a condition object of type &failed-expression.

Function: failed-expression-condition? obj

Return #t if obj is a condition object of type &failed-expression; otherwise return #f.

Function: condition-failed-expression cnd

Given a condition object of type &failed-expression return the symbolic expression.