aboutsummaryrefslogtreecommitdiff
path: root/src/clojure/contrib/condition/example.clj
diff options
context:
space:
mode:
Diffstat (limited to 'src/clojure/contrib/condition/example.clj')
-rw-r--r--src/clojure/contrib/condition/example.clj21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/clojure/contrib/condition/example.clj b/src/clojure/contrib/condition/example.clj
index 25ff74b6..e437cf6e 100644
--- a/src/clojure/contrib/condition/example.clj
+++ b/src/clojure/contrib/condition/example.clj
@@ -21,8 +21,25 @@
(defn main
[]
- (handler-case :source condition
+
+ ;; simple handler
+
+ (handler-case :source
(println (func 3 4))
(println (func -5 10))
(handle ::Args
- (printf "Bad argument: %s\n" condition))))
+ (printf "Bad argument: %s\n" *condition*)))
+
+ ;; demonstrate nested handlers
+
+ (handler-case :source
+ (handler-case :source
+ (println (func 8 2))
+ (println (func -6 17))
+ ;; no handler for ::Args
+ (handle ::nested
+ (printf "I'm nested: %s\n" *condition*)))
+ (println (func 3 4))
+ (println (func -5 10))
+ (handle ::Args
+ (printf "Bad argument: %s\n" *condition*))))