aboutsummaryrefslogtreecommitdiff
path: root/src/clojure/contrib/condition/example.clj
diff options
context:
space:
mode:
authorscgilardi <scgilardi@gmail.com>2009-06-11 03:52:50 +0000
committerscgilardi <scgilardi@gmail.com>2009-06-11 03:52:50 +0000
commit8711da996ee73bb21b94ec5a28cadc863bd422c1 (patch)
treecb6f6ba94a33cf595a462356c96909df52123aee /src/clojure/contrib/condition/example.clj
parent404289e834027a10ec8aaff75532cd5c5ce74641 (diff)
condition: refinements and add example of nested handler
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*))))