mirror of
https://github.com/penpot/penpot.git
synced 2025-06-16 00:21:41 +02:00
misc(backend): error middleware reorganization
This commit is contained in:
parent
7400f0f946
commit
57568f9614
3 changed files with 16 additions and 18 deletions
|
@ -5,26 +5,18 @@
|
|||
;; Copyright (c) 20162019 Andrey Antukh <niwi@niwi.nz>
|
||||
|
||||
(ns uxbox.api.errors
|
||||
"A errors handling for api."
|
||||
(:require [reitit.ring.middleware.exception :as exception]))
|
||||
|
||||
"A errors handling for api.")
|
||||
|
||||
(defmulti handle-exception #(:type (ex-data %)))
|
||||
|
||||
(defmethod handle-exception :validation
|
||||
[err]
|
||||
;; (println "\n*********** stack trace ***********")
|
||||
;; (.printStackTrace err)
|
||||
;; (println "\n********* end stack trace *********")
|
||||
(let [response (ex-data err)]
|
||||
{:status 400
|
||||
:body response}))
|
||||
|
||||
(defmethod handle-exception :default
|
||||
[err]
|
||||
;; (println "\n*********** stack trace ***********")
|
||||
;; (.printStackTrace err)
|
||||
;; (println "\n********* end stack trace *********")
|
||||
(let [response (ex-data err)]
|
||||
{:status 500
|
||||
:body response}))
|
||||
|
@ -78,9 +70,3 @@
|
|||
(.printStackTrace error)
|
||||
(println "\n********* end stack trace *********")
|
||||
(handler error request))
|
||||
|
||||
(def exception-middleware
|
||||
(exception/create-exception-middleware
|
||||
(assoc exception/default-handlers
|
||||
::exception/default errors-handler
|
||||
::exception/wrap wrap-print-errors)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue