Send exceptions to bugsnag.
Add to your dependencies in your project.clj:
[tocsin "0.1.1"]
The minimum needed is to call notify:
(ns myapp.core
(:require [tocsin.core :as tocsin]
[environ.core :refer [env]] ;; see https://github.com/weavejester/environ
...))
(try
... start app ...
(catch Exception e
(tocsin/notify e {:api-key (env :bugsnag-token)
:environment (env :environment)
:project-ns "myapp"})))
Here's the options broken down:
:api-key is your bugsnag project api key.:environment is the environment to report to bugsnag. By default only "production", "staging" "acceptance" environment exceptions are sent to bugsnag. We usually set this to "development" in our .lein-env to prevent local development exceptions getting reported in bugsnag. See :notify-release-stages below.:project-ns the namespace prefix for bugsnag to determine how to filter exceptions.Anytime you want to capture thrown exception just use try...catch with tocsin/notify.
tocsin/notify options are a pass-through to clj-bugsnag with the following changes:
:ex-data sent via clj-bugsnag no longer has a en-dash (ex–data) but just a hyphen (ex-data). Because it's harder to override clj-bugsnag's key.:unruly-ex-data-keys can be provided as a vector of keys to automatically dissoc from :ex-data. Defaults to #{:type :schema :system :component} which correspond to stuart-sierra's component exceptions that fail to start.:ex-data cannot be converted to json properly (probably because java classes are embedded in it), then tocsin will use prn-str on :ex-data and send the string through as a fallback.:notify-release-stages defaults to #{"production" "staging" "acceptance"}:unruly-ex-data-keys).Can you improve this documentation? These fine people already did:
Sheel Choksi & Jeff HuiEdit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |