Control Structures
These are examples of control structures. You may also be interested in:

 Conditional structures
 Exceptions
 Flow-control structures
 Loops

This task is to give an example of an exception handling routine
and to "throw" a new exception.



Related task

   Exceptions Through Nested Calls


(define-condition unexpected-odd-number (error)
  ((number :reader number :initarg :number))
  (:report (lambda (condition stream)
             (format stream "Unexpected odd number: ~w."
                     (number condition)))))
 
(defun get-number (&aux (n (random 100)))
  (if (not (oddp n)) n
    (error 'unexpected-odd-number :number n)))
 
(defun get-even-number ()
  (handler-case (get-number)
    (unexpected-odd-number (condition)
      (1+ (number condition)))))