This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-10
Channels
- # announcements (6)
- # architecture (2)
- # babashka (30)
- # beginners (90)
- # calva (21)
- # cider (22)
- # clj-kondo (27)
- # cljs-dev (7)
- # clojure (132)
- # clojure-europe (51)
- # clojure-nl (12)
- # clojure-norway (3)
- # clojure-spec (3)
- # clojure-uk (5)
- # clojurescript (69)
- # cloverage (9)
- # conjure (5)
- # core-async (54)
- # cursive (14)
- # datomic (34)
- # emacs (7)
- # fulcro (10)
- # graalvm (40)
- # graalvm-mobile (2)
- # gratitude (2)
- # improve-getting-started (1)
- # introduce-yourself (1)
- # jobs-discuss (61)
- # leiningen (5)
- # malli (6)
- # off-topic (59)
- # pathom (11)
- # polylith (38)
- # reagent (3)
- # reitit (3)
- # rewrite-clj (3)
- # shadow-cljs (53)
- # tools-build (35)
- # transit (8)
- # vim (62)
- # web-security (26)
- # xtdb (4)
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
(malli-coercion/create
{;; set of keys to include in error messages
:error-keys #{:humanized
;; :type
;; :coercion
;; :in
:schema
:value
:errors
#_:transformed}
;; 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 thisPondered the same the other day, ended up with simplistic helpers
(defn- path->str
[path]
(string/join " -> " (map #(if (number? %)
(str "[" % "]")
(name %))
path)))
(defn pretty-schema-error
"Make schema errors a bit more readable. Handles nil's and formats path."
[error]
(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.