异常处理

(defn throw-when-nil-or-empty [coll]
  (cond
    (nil? coll) (throw (IllegalArgumentException. "is nil"))
    (empty? coll) (throw (IllegalStateException. "is empty"))))

;; Exception catches any exception,
;; Throwable catches errors (OutOfMemoryError and friends) as well
(try
  (throw-when-nil-or-empty nil)
  (catch Exception e
    (println "Error happened" (.getSimpleName (class e)))))