Public Vars

Back

ex-data (clj)

(source)

function

(ex-data ex)
Returns exception data (a map) if ex is an IExceptionInfo. Otherwise returns nil.

Examples

clojure
(deftest division
  (is (= clojure.core// /))
  (binding [*ns* *ns*]
    (eval '(do (ns foo
                 (:require [clojure.core :as bar])
                 (:use [clojure.test]))
               (is (= clojure.core// bar//))))))

(defspec types-that-should-roundtrip
  roundtrip
  [^{:tag cgen/ednable} o]
  (when-not (= o %)
    (throw (ex-info "Value cannot roundtrip, see ex-data" {:printed o :read %}))))

(defspec types-that-need-dup-to-roundtrip
  roundtrip-dup
  [^{:tag cgen/dup-readable} o]
  (when-not (= o %)
    (throw (ex-info "Value cannot roundtrip, see ex-data" {:printed o :read %}))))
clojure
(ns clojure.test-clojure.server
    (:import java.util.Random)
    (:require [clojure.test :refer :all])
    (:require [clojure.core.server :as s]))

(defn check-invalid-opts
  [opts msg]
  (try
    (#'clojure.core.server/validate-opts opts)
    (is nil)
    (catch Exception e
      (is (= (ex-data e) opts))
      (is (= msg (.getMessage e))))))
pedestal/pedestal
(ns io.pedestal.interceptor.error
  (:require [io.pedestal.interceptor :as interceptor]
            [clojure.core.match :as match]))

(defmacro error-dispatch
  "Return an interceptor for doing pattern-matched error-dispatch, based on
  the ex-data of the exception.
  Pedestal wraps *all* exceptions in ex-info on error, providing the following
  keys to match on: `:execution-id`, `:stage`, `:interceptor`, `:exception-type`

  `:exception-type` is a keyword of the exception's type, for example,
  `:java.lang.ArithmeticException
  "
  [binding-vector & match-forms]
  `(io.pedestal.interceptor/interceptor
     {:error (fn ~binding-vector
               (clojure.core.match/match [(ex-data ~(second binding-vector))]
                  ~@match-forms))}))
thheller/shadow-cljs
(ns shadow.remote.runtime.cljs.js-builtins
  (:require
    [goog.object :as gobj]
    [clojure.core.protocols :as p]))

  js/Error
  (datafy [e]
    (let [data (ex-data e)
          file (.-fileName e)
          line (.-lineNumber e)
          column (.-columnNumber e)]
      (-> {:message (.-message e)
           :name (.-name e)
           :stack (.-stack e)}
          (cond->
            (some? data)
            (assoc :data data)
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))))

cc/rand [(t/? t/Num) :-> t/Num]
cc/rand-int [t/Int :-> t/Int]
cc/ex-info (t/IFn [(t/Nilable t/Str) (t/Map t/Any t/Any) :-> t/ExInfo]
                  [(t/Nilable t/Str) (t/Map t/Any t/Any) (t/? #?(:clj (t/Nilable Throwable) :cljs t/Any)) :-> t/ExInfo])
cc/ex-data (t/IFn [t/ExInfo :-> (t/Map t/Any t/Any)]
                  [t/Any :-> (t/Nilable (t/Map t/Any t/Any))])
cc/ex-message [t/Any :-> (t/Nilable t/Str)]
cc/ex-cause [t/Any :-> #?(:clj (t/Nilable Throwable) :cljs t/Any)]
cognitect-labs/day-of-datomic-cloud
(require '[datomic.client.api.async :as d]
         '[clojure.core.async :refer (<!!)])

(d/q {:query '[:find (count ?name)
               :where [_ :artist/name ?name]]
      :args [db]
      :timeout 1})
(ex-data *e)
 
breadsystems/bread-cms
;; TODO migrate to CLJC
(ns systems.bread.alpha.plugin.datahike
  (:require
    [clojure.core.protocols :refer [Datafiable]]
    [datahike.api :as d]
    [datahike.db :as dhdb]
    [systems.bread.alpha.schema :as schema]
    [systems.bread.alpha.core :as bread]
    [systems.bread.alpha.database :as db])
  (:import
    [java.lang IllegalArgumentException]
    [java.util UUID]))

(defmethod db/create! :datahike [config & [{:keys [force?]}]]
  (try
    (d/create-database config)
    (catch clojure.lang.ExceptionInfo e
      (let [exists? (= :db-already-exists (:type (ex-data e)))]
        (when (and force? exists?)
          (d/delete-database config)
          (d/create-database config))))))