mirror of
https://github.com/metosin/reitit.git
synced 2026-02-22 01:59:09 +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))
|
||||
ks)))
|
||||
|
||||
(defn- descendants-safe [type]
|
||||
(when-not (class? type) (descendants type)))
|
||||
(defn- ancestors-safe [type]
|
||||
(when-not (class? type) (ancestors type)))
|
||||
|
||||
(defn- call-error-handler [handlers error request]
|
||||
(let [type (:type (ex-data error))
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
(get handlers ex-class)
|
||||
(some
|
||||
(partial get handlers)
|
||||
(descendants-safe type))
|
||||
(ancestors-safe type))
|
||||
(some
|
||||
(partial get handlers)
|
||||
(super-classes ex-class))
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
(:import (clojure.lang ExceptionInfo)
|
||||
(java.sql SQLException SQLWarning)))
|
||||
|
||||
(derive ::kikka ::kukka)
|
||||
(derive ::kukka ::kikka)
|
||||
|
||||
(deftest exception-test
|
||||
(letfn [(create
|
||||
|
|
|
|||
Loading…
Reference in a new issue