Skip to content

Instantly share code, notes, and snippets.

@omartell
Created March 23, 2014 20:20
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 omartell/9729269 to your computer and use it in GitHub Desktop.
Save omartell/9729269 to your computer and use it in GitHub Desktop.
ring-bugsnag
(ns your-app.ring-bugsnag
(:import
[com.bugsnag Client MetaData]))
(def client
(doto (Client. "your api key goes here")
(.setReleaseStage "development")
(.setNotifyReleaseStages (into-array String ["staging" "production"]))))
(defn notify
([error metadata]
(.notify client error metadata)))
(defn metadata
[req]
(let [metadata (MetaData.)]
(doseq [[k v] req]
(.addToTab metadata "Request" (str k) (str v)))
metadata))
(defn wrap-bugsnag
[handler]
(fn [req]
(try
(handler req)
(catch Throwable t
(notify t (metadata req))
(throw t)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment