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