Created
April 20, 2012 14:27
-
-
Save stuartsierra/2429063 to your computer and use it in GitHub Desktop.
Example error messages from common mistakes with Datomic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Some example error messages resulting from common mistakes | |
;; using Datomic 0.8.4138 | |
(ns errors | |
(:use [datomic.api :as d :only (db q)])) | |
(def uri "datomic:mem://database") | |
(d/create-database uri) | |
(def conn (d/connect uri)) | |
(defn find-attribute [keyword] | |
(q '[:find ?attr :in $ ?name :where [?attr :db/ident ?name]] | |
(db conn) | |
keyword)) | |
(comment | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; OK: | |
(find-attribute :db/cardinality) | |
;; If I mistakenly pass a nil as an input: | |
(find-attribute nil) | |
;; Exception Unable to find data source: $234 in: ($234 $) | |
;; datomic.datalog/eval-rule/fn--4697 (datalog.clj:968) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; OK: | |
(d/transact conn [[:db/add (d/tempid :db.part/user) :db/ident :foo]]) | |
;; If I mistakenly add an extra layer of nesting: | |
(d/transact conn [[[:db/add (d/tempid :db.part/user) :db/ident :foo]]]) | |
;; ExceptionInfo :db/bad-keyword Can't find config/Symbolish support | |
;; for: [:db/add #db/id[:db.part/user -1000001] :db/ident :foo] of | |
;; class: class clojure.lang.PersistentVector clojure.core/ex-info | |
;; (core.clj:4327) | |
;; If I mistakenly commit a nil: | |
(d/transact conn [[nil]]) | |
;; ExceptionInfo :transact/bad-data Unable to resolve data function: | |
;; clojure.core/ex-info (core.clj:4327) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist is now quite old (2012) and was never intended to be a reference for Datomic error messages. Do not assume it is an accurate representation of anything.
(Comment as of version 44491fd95f10c34c9af40477436cfe7a790190d6)