Skip to content

Instantly share code, notes, and snippets.

@dhobbs
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhobbs/9765864 to your computer and use it in GitHub Desktop.
Save dhobbs/9765864 to your computer and use it in GitHub Desktop.
Nested defs
(ns meow.alerts
(:require [clojure.stacktrace :refer [print-stack-trace]]))
(defmacro safely [body]
`(try ~body
(catch java.lang.Throwable e#
(println "Caught exception while trying to report a problem:" (.getMessage e#))
(print-stack-trace e#))))
(defn init! [sms-send server]
(defn fatal
"I'm crashing to a fiery death, email and text everyone, dump the logs and head for the hills."
([message]
(safely (sms-send message))
(safely ((:fatal server) message)))
([]
(fatal "She's gonnae blow cap'n")))
(defn warn
[message]
(safely ((:warn server) message) ))
(defn info [message]
(safely ((:info server) message))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment