mirror of
https://github.com/metosin/reitit.git
synced 2026-02-08 12:53:12 +00:00
fix: create-exception-middleware for hierarchical keywords
Previously, the code was searching among the descendants, not the ancestors, of the error type for an error handler. The test also got this wrong, perhaps due to a mistake in the parameter order of derive.
This commit is contained in:
parent
c3a152a44e
commit
2c87d90bda
2 changed files with 4 additions and 4 deletions
|
|
@ -19,8 +19,8 @@
|
||||||
(recur (.getSuperclass sk) (conj ks sk))
|
(recur (.getSuperclass sk) (conj ks sk))
|
||||||
ks)))
|
ks)))
|
||||||
|
|
||||||
(defn- descendants-safe [type]
|
(defn- ancestors-safe [type]
|
||||||
(when-not (class? type) (descendants type)))
|
(when-not (class? type) (ancestors type)))
|
||||||
|
|
||||||
(defn- call-error-handler [handlers error request]
|
(defn- call-error-handler [handlers error request]
|
||||||
(let [type (:type (ex-data error))
|
(let [type (:type (ex-data error))
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
(get handlers ex-class)
|
(get handlers ex-class)
|
||||||
(some
|
(some
|
||||||
(partial get handlers)
|
(partial get handlers)
|
||||||
(descendants-safe type))
|
(ancestors-safe type))
|
||||||
(some
|
(some
|
||||||
(partial get handlers)
|
(partial get handlers)
|
||||||
(super-classes ex-class))
|
(super-classes ex-class))
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
(:import (clojure.lang ExceptionInfo)
|
(:import (clojure.lang ExceptionInfo)
|
||||||
(java.sql SQLException SQLWarning)))
|
(java.sql SQLException SQLWarning)))
|
||||||
|
|
||||||
(derive ::kikka ::kukka)
|
(derive ::kukka ::kikka)
|
||||||
|
|
||||||
(deftest exception-test
|
(deftest exception-test
|
||||||
(letfn [(create
|
(letfn [(create
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue