(defn- f-name [f] (or (disasm f :name) "f")) (defn- error-context [k] ((dyn :error-context) k)) (defn- spec-name [] (string (error-context :spec-name))) (defn- format-renderer-context [] (let [cxt (error-context :render-context)] (if (any? [cxt]) (string/format ``` Current render context: %q ``` cxt) ""))) (defn eval-error [sym filename] (error (string "Expected symbol " sym "; couldn't be found after evaluating " filename))) (defn path-error [err f args-type] (let [err (string/format ``` Encountered error generating path for site spec %s: %s. Expected path function signature: (defn %s %s "foo/bar/...") ``` (spec-name) err (f-name f) (case args-type :d "[data]" :di "[data item]"))] (error err))) (defn renderer-error [err f args-type] (let [err (string/format ``` Encountered error rendering output for site spec %s: %s. %s Expected renderer function signature: (defn %s %s "...") ``` (spec-name) err (format-renderer-context) (f-name f) (case args-type :d "[data]" :di "[data item]"))] (error err))) (defn attrs-error [err attrs-f] (error (string/format ``` Encountered error getting attrs for data spec %s: %s. Expected parse function signature: (defn %s [src attrs] attrs) ``` (spec-name) err (or (disasm attrs-f :name) "f")))) (defn data-error [spec] (error (string/format ``` Received invalid data spec: %q Specification can be one of the following: {:src (loader|path) :attrs parser)} {:attrs attrs} ``` spec))) (defn site-error [spec] (error (string/format ``` Received invalid site spec: %q Specification can be one of the following: {:each site-selector :dest path-generator :out renderer} (write) {:each site-selector :dest path-generator} (copy) {:dest (path|path-generator) :out (contents|renderer)} (write) {:some site-selector :dest (path|path-generator)} (copy) ``` spec)))