Public Vars

Back

set-error-mode! (clj)

(source)

function

(set-error-mode! a mode-keyword)
Sets the error-mode of agent a to mode-keyword, which must be either :fail or :continue. If an action being run by the agent throws an exception or doesn't pass the validator fn, an error-handler may be called (see set-error-handler!), after which, if the mode is :continue, the agent will continue as if neither the action that caused the error nor the error itself ever happened. If the mode is :fail, the agent will become failed and will stop accepting new 'send' and 'send-off' actions, and any previously queued actions will be held until a 'restart-agent'. Deref will still work, returning the state of the agent before the error.

Examples

typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
  "Type annotations for the base Clojure distribution."
  #?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
  (:require [clojure.core :as cc]
            [typed.clojure :as t]
            #?(:clj [typed.ann-macros.clojure :as macros])
            #?(:clj typed.ann.clojure.jvm) ;; jvm annotations
            #?(:clj clojure.core.typed))
  #?(:clj
     (:import (clojure.lang PersistentHashSet PersistentList
                            APersistentMap #_IPersistentCollection
                            #_ITransientSet
                            IRef)
              (java.util Comparator Collection))))

#?@(:cljs [] :default [
cc/agent-error [t/AnyAgent :-> (t/Nilable Throwable)]
cc/restart-agent (t/All [x] [(t/Agent x) x & :optional {:clear-actions t/Any} :-> t/Any])
cc/set-error-handler! (t/All [x] [(t/Agent x) [(t/Agent x) Throwable :-> t/Any] :-> t/Any])
cc/error-handler (t/All [[a :< t/AnyAgent]] [a :-> (t/Nilable [a Throwable :-> t/Any])])
cc/set-error-mode! [t/AnyAgent (t/U ':fail ':continue) :-> t/Any]
cc/error-mode [t/AnyAgent :-> t/Any]
cc/agent-errors [t/AnyAgent :-> (t/Nilable (t/ASeq Throwable))]
cc/clear-agent-errors [t/AnyAgent :-> t/Any]
cc/shutdown-agents [:-> t/Any]
])