Liking cljdoc? Tell your friends :D

Error Messages

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.

Default Errors

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"]])

Pretty error

Pretty Errors

[metosin/reitit-dev "0.7.0-alpha2"]

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})

Pretty error

Extending

Behind the scenes, both error formatters are backed by a multimethod, so they are easy to extend.

More examples

See the validating route data page.

Runtime Exception

See Exception Handling with Ring.

Can you improve this documentation? These fine people already did:
Tommi Reiman, Miikka Koskinen, Juho Teperi, Raphaël Saunier, David Harrigan & Marcus Spiegel
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close