Back

error (clj)

(source)

macro

(error & args)

Examples

timbre
(ns taoensso.timbre-tests
  (:require
   [clojure.test    :as test :refer [deftest testing is]]
   [taoensso.encore :as enc]
   [taoensso.timbre :as timbre])

   (is (= (timbre/set-ns-min-level {:min-level [["a.b" :trace] ["a.c" :debug] ["a.*" :info] ["a.c" :error]]}
            "a.c" :report)
         {:min-level [["a.c" :report] ["a.b" :trace] ["a.*" :info]]}))

      (is (not     (:error-level? (log-data "ns" :info  {:min-level :info}  {} []))))
      (is (boolean (:error-level? (log-data "ns" :error {:min-level :error} {} []))))])

(deftest special-args
  [(testing "Special-args/errors"
     [(is (nil?       (:?err  (log-data "ns" :report {} {} ["foo"                  ]))))
      (is (enc/error? (:?err  (log-data "ns" :report {} {} [(ex-info "ex" {}) "foo"]))) "First-arg ex -> :?err")
      (is (enc/error? (:?err  (log-data "ns" :report {} {} [(ex-info "ex" {})      ]))) "First-arg ex -> :?err")
      (is (= ["foo"]  (:vargs (log-data "ns" :report {} {} [(ex-info "ex" {}) "foo"]))) "First-arg ex dropped from vargs")
      (is (= []       (:vargs (log-data "ns" :report {} {} [(ex-info "ex" {})      ]))) "First-arg ex dropped from vargs")])
fulcrologic/fulcro
(ns com.fulcrologic.fulcro.cards.error-boundary-cards
  (:require
    [nubank.workspaces.card-types.fulcro3 :as ct.fulcro]
    [nubank.workspaces.core :as ws]
    [com.fulcrologic.fulcro.application :as app]
    [com.fulcrologic.fulcro.components :as comp :refer [defsc]]
    [com.fulcrologic.fulcro.dom :as dom]
    [com.fulcrologic.fulcro.mutations :as m]
    [taoensso.timbre :as log]))

(defsc Child [this {:child/keys [id name actor] :as props}]
  {:query                    [:child/id :child/name {:child/actor (comp/get-query BadActor)}]
   :ident                    :child/id
   :componentDidCatch        (fn [this err info] (log/spy :error [err info]))
   :getDerivedStateFromError (fn [error]
                               (log/spy :info error)
                               {:error? true})
   :initial-state            {:child/id    :param/id :child/name :param/name
                              :child/actor {:id :param/id}}}
  (if (log/spy :info (comp/get-state this :error?))
    (dom/div
      "There was an error in this part of the UI."
      (dom/button {:onClick #(comp/set-state! this {:error? false})} "Retry"))
    (dom/div
      (dom/label "Child: " name)
      (ui-bad-actor actor {:reset? (contains? (comp/get-state this) :error?)}))))

(ws/defcard error-boundary-card
  (ct.fulcro/fulcro-card
    {::ct.fulcro/wrap-root? false
     ::ct.fulcro/root       Root
     ::ct.fulcro/app        {}}))
braidchat/braid
(ns braid.core.server.routes.api.private
  (:require
   [braid.core.server.db :as db]
   [braid.chat.db.group :as group]
   [braid.chat.events :as events]
   [braid.base.server.cqrs :as cqrs]
   [braid.core.server.routes.helpers :as helpers :refer [error-response edn-response]]
   [braid.lib.markdown :refer [markdown->hiccup]]
   [clojure.java.io :as io]
   [clojure.string :as string]
   [compojure.core :refer [GET PUT DELETE defroutes]]
   [taoensso.timbre :as timbre]))

  (PUT "/groups/:group-id/join" [group-id :as req]
    (let [group-id (java.util.UUID/fromString group-id)]
      (cond
        ; logged in?
        (not (helpers/logged-in? req))
        (error-response 401 "Must be logged in.")

        ; public group?
        (not (:public? (group/group-by-id group-id)))
        (error-response 401 "Can only join public group via this endpoint")
carneades/carneades-3
(ns eu.markosproject.licensing.oss-licensing-theory
  (:require  [carneades.engine.dublin-core :as dc]
             [carneades.engine.theory :as t]
             [carneades.engine.argument :as a]
             [carneades.engine.statement :as s]
             [carneades.owl.import :as owl]
             [carneades.project.fs :as project]
             [taoensso.timbre :as timbre :refer [debug error spy]]))

;; (def oss-licensing-ontology
;;   (try
;;     (owl/import-from-project "markos" "ontologies/MARKOS/markos-licenses.owl")
;;     (catch Exception e
;;       (error "Error loading markos-copyright.owl")
;;       (error "If you don't use the MARKOS project, ignore this.")
;;       (error "Error:" e)
;;       {})))
untangled-web/untangled-cookbook
(ns app.api
  (:require [om.next.server :as om]
            [om.next.impl.parser :as op]
            [taoensso.timbre :as timbre]))

(defmethod apimutate :default [e k p]
  (timbre/error "Unrecognized mutation " k))

(defmethod api-read :default [{:keys [ast query] :as env} dispatch-key params]
    (timbre/error "Unrecognized query " (op/ast->expr ast)))
untangled-web/untangled-cookbook
(ns app.api
  (:require [om.next.server :as om]
            [om.next.impl.parser :as op]
            [taoensso.timbre :as timbre]))

(defmethod apimutate :default [e k p]
  (timbre/error "Unrecognized mutation " k))

(defmethod api-read :default [{:keys [ast query] :as env} dispatch-key params]
    (timbre/error "Unrecognized query on dispatch key " dispatch-key (op/ast->expr ast)))