All exceptions thrown in router creation are caught, formatted and rethrown by the reitit.core/router
function. Exception formatting is done by the exception formatter defined by the :exception
router option.
The default exception formatting uses reitit.exception/exception
. It produces single-color, partly human-readable, error messages.
(require '[reitit.core :as r])
(r/router
[["/ping"]
["/:user-id/orders"]
["/bulk/:bulk-id"]
["/public/*path"]
["/:version/status"]])
[metosin/reitit-dev "0.5.12"]
For human-readable and developer-friendly exception messages, there is reitit.dev.pretty/exception
(in the reitit-dev
module). It is inspired by the lovely errors messages of ELM and ETA and uses fipp, expound and spell-spec for most of heavy lifting.
(require '[reitit.dev.pretty :as pretty])
(r/router
[["/ping"]
["/:user-id/orders"]
["/bulk/:bulk-id"]
["/public/*path"]
["/:version/status"]]
{:exception pretty/exception})
Behind the scenes, both error formatters are backed by a multimethod, so they are easy to extend.
See the validating route data page.
Can you improve this documentation? These fine people already did:
Tommi Reiman, Raphaël Saunier, David Harrigan, Miikka Koskinen & Marcus SpiegelEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close