Skip to content

Commit

Permalink
Fixed wrap-validation-errors default error-handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Deraen committed Mar 2, 2015
1 parent b70a219 commit f958d23
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.18.1 (2.3.2015)

- Fixed wrap-validation-errors defaults

## 0.18.0 (2.3.2015)
- fixed Swagger 2.0 response bug [#29](https://github.com/metosin/ring-swagger/issues/29)
- `ring.swagger.swagger2/swagger-json` now takes an optional extra argument, the Options-map
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject metosin/ring-swagger "0.18.0"
(defproject metosin/ring-swagger "0.18.1"
:description "Swagger Spec for Ring Apps"
:url "https://github.com/metosin/ring-swagger"
:license {:name "Eclipse Public License"
Expand Down
9 changes: 4 additions & 5 deletions src/ring/swagger/middleware.clj
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@
:error-handler - a function of schema.utils.ErrorContainer -> response
:catch-core-errors? - consume also :schema.core/errors (defaults to false)"
[handler & [{:keys [error-handler catch-core-errors?]
:or {error-handler default-error-handler
catch-core-errors? false}}]]
(fn [request]
[handler & [{:keys [error-handler catch-core-errors?]}]]
(let [error-handler (or error-handler default-error-handler)]
(fn [request]
(try+
(handler request)
(catch [:type :schema.core/error] validation-error
(if catch-core-errors?
(error-handler validation-error)
(throw+ validation-error)))
(catch [:type :ring.swagger.schema/validation] error-container
(error-handler error-container)))))
(error-handler error-container))))))

0 comments on commit f958d23

Please sign in to comment.