store/[org.clojure/clojure "1.8.0"] clj::clojure.core/set-error-handler!

Official Documentation

Add notes
Arities
==================================================
   [a handler-fn]

Docstring
==================================================
  Sets the error-handler of agent a to handler-fn.  If an action
  being run by the agent throws an exception or doesn't pass the
  validator fn, handler-fn will be called with two arguments: the
  agent and the exception.

Source

(defn set-error-handler!
  "Sets the error-handler of agent a to handler-fn.  If an action
  being run by the agent throws an exception or doesn't pass the
  validator fn, handler-fn will be called with two arguments: the
  agent and the exception."
  {:added "1.2"
   :static true}
  [^clojure.lang.Agent a, handler-fn]
  (.setErrorHandler a handler-fn))

Example 1

Edit
(def bond (agent 7))
;; => #'user/bond

(defn err-handler-fn [ag ex]
  (println "evil error occured: " ex " and we still have value " @ag))
;; => #'user/err-handler-fn

(set-error-handler! bond err-handler-fn)

;; division by zero:
(send bond (fn [x] (/ x 0)))
;; > evil error occured:  #<ArithmeticException java.lang.ArithmeticException: 
;; > Divide by zero>  and we still have value  7

(send bond inc)
;; => FAILURE
;; Agent is failed, needs restart, but keeps the last OK value

@bond
;; => 7

(restart-agent bond 7) ;; or replace 7 with @ag

(send bond inc)
;; => #<Agent@88d00c6: 7>

@bond
;; => 8

Uses on crossclj