File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,8 +55,8 @@ Each key has a configuration map to define a handler for a specific HTTP method
5555(def router
5656 (ring/ring-handler
5757 (ring/router
58- [[" /" {:get welcome}]]
59- [" /status" {:get status}])))
58+ [[" /" {:get welcome}]
59+ [" /status" {:get status}] ])))
6060```
6161
6262!!! HINT "Passing system configuration argument"
@@ -116,3 +116,40 @@ Handler functions are Clojure functions that take a request map.
116116 (constantly (response {:application "practicalli awesome-api Service" :status "Alive"})))
117117 ```
118118
119+
120+ ## Error Messages
121+
122+ When the router is created from its definition, Reitit will show errors using basic formatting to make them a little more readable.
123+
124+ Using ` reitit.dev.pretty/exception ` provides human readable and development friendly exception messages.
125+
126+
127+ !!! EXAMPLE "Add the reditit.dev library"
128+ ```clojure title="deps.edn"
129+ : deps
130+ {
131+ http-kit/http-kit {: mvn /version "2.8.0"}
132+ metosin/reitit {: mvn /version "0.7.0"}
133+ metosin/reitit-dev {: mvn /version "0.7.0"} ; human readable exceptions
134+ }
135+ ;; ---------------------------------------------------------
136+ ```
137+
138+ Update the Reitit router configuration to provide an exception that will process errors using ` pretty/exception `
139+
140+ !!! EXAMPLE "Add and Exception catch to the router definition"
141+ ```clojure
142+ (: require
143+ [ reitit.ring : as ring]
144+ [ reitit.dev.pretty : as pretty] )
145+
146+ (def router
147+ (ring/ring-handler
148+ (ring/router
149+ [["/" {:get welcome}]
150+ ["/status" {:get status}]]
151+ {:exception pretty/exception})))
152+ ```
153+
154+
155+ [ Pretty Errors - Reitit Docs] ( https://cljdoc.org/d/metosin/reitit/0.10.1/doc/basics/error-messages#pretty-errors ) {target=_ blank .md-button}
You can’t perform that action at this time.
0 commit comments