Created
March 23, 2014 20:20
-
-
Save omartell/9729269 to your computer and use it in GitHub Desktop.
ring-bugsnag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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