Send exceptions to bugsnag.
Add to your dependencies in your project.clj:
[tocsin "0.2.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-keyis your bugsnag project api key.:environmentis 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-envto prevent local development exceptions getting reported in bugsnag. See:notify-release-stagesbelow.:project-nsthe 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-datasent 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-keyscan 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.- If
:ex-datacannot be converted to json properly (probably because java classes are embedded in it), then tocsin will useprn-stron:ex-dataand send the string through as a fallback. :notify-release-stagesdefaults to#{"production" "staging" "acceptance"}- Unlike clj-bugsnag, all options are passed to bugsnag (except
:unruly-ex-data-keys).