Skip to content

Instantly share code, notes, and snippets.

@timcharper
Created June 15, 2010 23:27
Show Gist options
  • Save timcharper/439900 to your computer and use it in GitHub Desktop.
Save timcharper/439900 to your computer and use it in GitHub Desktop.
(ns clojure.contrib.condition.example
(:use clojure.contrib.condition))
(defn func [x y]
(if (neg? x)
(raise :type :arg :message "shouldn't be negative")
(+ x y)))
(defn run
[]
(handler-case :type
(println (func 3 4))
(println (func -5 10))
(handle :arg
(printf "Bad argument: %s\n" (:message *condition*)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment