Fork me on GitHub

Hello. Is there a way to make the exception-info created by Malli coercion less verbose? Currently 500 lines of output to the terminal is a bit hard to parse, mostly because the exception info includes a lot of information about the request. Either that or a better way to print only the relevant parts of the exception would also be appreciated.


(def malli-coercer
   {;; set of keys to include in error messages
    :error-keys #{:humanized
              ;;     :type
              ;;     :coercion
              ;;     :in
   ;; schema identity function (default: close all map schemas)
    :compile mu/closed-schema
   ;; validate request & response
    :validate true
   ;; top-level short-circuit to disable request & response coercion
    :enabled true
   ;; malli options
    :options nil
    :muuntaja formats/instance}))
My Coercion is setup like this




Not sure how to apply that to exception-info


Pondered the same the other day, ended up with simplistic helpers

(defn- path->str
  (string/join " -> " (map #(if (number? %)
                              (str "[" % "]")
                              (name %))

(defn pretty-schema-error
  "Make schema errors a bit more readable. Handles nil's and formats path."
  (let [path (:path error)
        type (:type error)]
    {:path (path->str path)
     :type (if (nil? type) "nil" (name type))})) 
Using it in our reitit API when handling :reitit.coercion/request-coercion errors for example.