0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-16 01:31:22 -05:00

Add extensible error handling to rstore impl.

This commit is contained in:
Andrey Antukh 2016-05-16 13:27:52 +03:00
parent ef47a0aaad
commit 05df84e89c
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95

View file

@ -86,21 +86,21 @@
(enable-console-print!)
(defn- on-error
"A default error handler."
[error]
(cond
(and (:status error)
(:payload error)
(= (:status error) 403))
(emit! (uxbox.data.auth/logout))
(defonce ^:private error-handlers (atom {}))
:else
(do
(uxbox.data.messages/error! (tr "errors.generic"))
(println "Unexpected error: " error)
(js/console.log (.-stack error))
(rx/throw error))))
(defn add-error-watcher
[key callable]
(swap! error-handlers assoc key callable))
(defn remove-error-watcher
[key]
(swap! error-handlers dissoc key))
(defn- on-error
[error]
(doseq [[key value] @error-handlers]
(value error))
(throw error))
(defn init
"Initializes the stream event loop and