Error Handling
(defun slope (x1 y1 x2 y2)
(/ (- y2 y1) (- x2 x1)))
(defun print-slope (x1 y1 x2 y2)
(handler-case
(print (slope x1 y1 x2 y2))
(division-by-zero ()
(print :infinite))
(error (c)
(princ c))))
(print-slope 0 5 0 10) -> :infinite
(print-slope 0 5 NIL NIL) -> “nil is not a number”
Previous slide
Next slide
Back to first slide
View graphic version