mirror of
https://github.com/metosin/reitit.git
synced 2025-12-17 08:21:11 +00:00
Polish errors
This commit is contained in:
parent
aff2229151
commit
8e2e0c07f6
5 changed files with 14 additions and 11 deletions
|
|
@ -73,14 +73,17 @@
|
|||
(seq)
|
||||
(into {})))
|
||||
|
||||
(defn throw-on-conflicts! [conflicts]
|
||||
(throw
|
||||
(ex-info
|
||||
(apply str "router contains conflicting routes:\n\n"
|
||||
(defn conflicts-str [conflicts]
|
||||
(apply str "Router contains conflicting routes:\n\n"
|
||||
(mapv
|
||||
(fn [[[path] vals]]
|
||||
(str " " path "\n-> " (str/join "\n-> " (mapv first vals)) "\n\n"))
|
||||
conflicts))
|
||||
conflicts)))
|
||||
|
||||
(defn throw-on-conflicts! [conflicts]
|
||||
(throw
|
||||
(ex-info
|
||||
(conflicts-str conflicts)
|
||||
{:conflicts conflicts})))
|
||||
|
||||
(defn name-lookup [[_ {:keys [name]}] opts]
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@
|
|||
missing (clojure.set/difference required defined)]
|
||||
(throw
|
||||
(ex-info
|
||||
(str "missing path-params for route " template ": " missing)
|
||||
(str "missing path-params for route " template " -> " missing)
|
||||
{:params params, :required required})))))
|
||||
|
||||
(defn fast-assoc
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
;; routes
|
||||
;;
|
||||
|
||||
(s/def ::path (s/with-gen (s/and string? #(str/starts-with? % "/"))
|
||||
(s/def ::path (s/with-gen (s/and string? #(or (str/blank? %) (str/starts-with? % "/")))
|
||||
#(gen/fmap (fn [s] (str "/" s)) (s/gen string?))))
|
||||
|
||||
(s/def ::arg (s/and any? (complement vector?)))
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
(s/def ::raw-route
|
||||
(s/cat :path ::path
|
||||
:arg (s/? ::arg)
|
||||
:childs (s/* (s/and ::raw-route))))
|
||||
:childs (s/* (s/and (s/nilable ::raw-route)))))
|
||||
|
||||
(s/def ::raw-routes
|
||||
(s/or :route ::raw-route
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
(is (= true (reitit/partial-match? (reitit/match-by-name router ::beer))))
|
||||
(is (thrown-with-msg?
|
||||
ExceptionInfo
|
||||
#"^missing path-params for route /api/ipa/:size: \#\{:size\}$"
|
||||
#"^missing path-params for route /api/ipa/:size -> \#\{:size\}$"
|
||||
(reitit/match-by-name! router ::beer))))))
|
||||
|
||||
(testing "lookup-router"
|
||||
|
|
@ -197,7 +197,7 @@
|
|||
(testing "throws by default"
|
||||
(is (thrown-with-msg?
|
||||
ExceptionInfo
|
||||
#"router contains conflicting routes"
|
||||
#"Router contains conflicting routes"
|
||||
(reitit/router
|
||||
[["/a"] ["/a"]]))))
|
||||
(testing "can be configured to ignore"
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@
|
|||
(reitit/router
|
||||
["/api"] opts)))
|
||||
|
||||
{:path ""}
|
||||
{:path "api"}
|
||||
{:path nil}
|
||||
{:meta nil}
|
||||
{:expand nil}
|
||||
|
|
|
|||
Loading…
Reference in a new issue