Public Vars

Back

error-mode (clj)

(source)

function

(error-mode a)
Returns the error-mode of agent a. See set-error-mode!

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/get-thread-bindings [:-> (t/Map t/AnyVar t/Any)]
cc/bound-fn*
    (t/All [r b :..]
         [[b :.. b :-> r] :-> [b :.. b :-> r]])
cc/find-var
    [t/Sym :-> (t/Nilable t/AnyVar)]
cc/agent
    (t/All [x] [x & :optional {:validator (t/Nilable [x :-> t/Any]) :meta t/Any
                               :error-handler (t/Nilable [(t/Agent x) Throwable :-> t/Any])
                               :error-mode (t/U ':continue ':fail)} 
                :-> (t/Agent x)])
cc/set-agent-send-executor! [java.util.concurrent.ExecutorService :-> t/Any]
cc/set-agent-send-off-executor! [java.util.concurrent.ExecutorService :-> t/Any]
cc/send-via (t/All [x b :..] [(t/Agent x) [x b :.. b :-> x] b :.. b :-> (t/Agent x)])
cc/send (t/All [x b :..] [(t/Agent x) [x b :.. b :-> x] b :.. b :-> (t/Agent x)])
cc/send-off (t/All [x b :..] [(t/Agent x) [x b :.. b :-> x] b :.. b :-> (t/Agent x)])
cc/await [t/AnyAgent :* :-> nil]
cc/await-for [t/AnyInteger t/AnyAgent :* :-> t/Bool]
cc/await1 (t/All [[a :< t/AnyAgent]] [a :-> (t/Nilable a)])
cc/release-pending-sends [:-> t/AnyInteger]
])

#?@(: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]
])
wilkerlucio/pathom3
(ns com.wsscode.pathom3.interface.smart-map-test
  (:require
    [clojure.core.protocols :as d]
    [clojure.test :refer [deftest is are run-tests testing]]
    [com.wsscode.pathom3.connect.built-in.resolvers :as pbir]
    [com.wsscode.pathom3.connect.indexes :as pci]
    [com.wsscode.pathom3.connect.operation :as pco]
    [com.wsscode.pathom3.entity-tree :as p.ent]
    [com.wsscode.pathom3.interface.smart-map :as psm]
    [com.wsscode.pathom3.test.geometry-resolvers :as geo]
    [com.wsscode.pathom3.test.helpers :as th]
    [matcher-combinators.test])
  #?(:clj
     (:import
       (clojure.lang
         ExceptionInfo))))

  (testing "loud mode"
    (let [sm (-> (pci/register error-resolver)
                 (psm/with-error-mode ::psm/error-mode-loud)
                 (psm/smart-map))]
      (is (thrown?
            #?(:clj ExceptionInfo :cljs js/Error)
            (:error sm))))

    (testing "planning error"
      (is (thrown?
            #?(:clj ExceptionInfo :cljs js/Error)
            (let [m (psm/smart-map (-> (pci/register
                                         (pbir/alias-resolver :x :y))
                                       (psm/with-error-mode ::psm/error-mode-loud))
                      {})]
              (:y m)))))))