Fix incorrect handling of error message timeouts.

This commit is contained in:
Andrey Antukh 2017-02-21 17:49:17 +01:00
parent 8f08a23615
commit 0bb8fa7e06
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95
2 changed files with 6 additions and 11 deletions

View file

@ -51,31 +51,26 @@
(defn- on-error (defn- on-error
"A default error handler." "A default error handler."
[{:keys [status] :as error}] [{:keys [status] :as error}]
(js/console.log "on-error:" (pr-str error)) (js/console.error "on-error:" (pr-str error))
(js/console.log "stack:" (.-stack error))
(reset! st/loader false) (reset! st/loader false)
(cond (cond
;; Unauthorized or Auth timeout ;; Unauthorized or Auth timeout
(and (:status error) (and (:status error)
(or (= (:status error) 403) (or (= (:status error) 403)
(= (:status error) 419))) (= (:status error) 419)))
(st/emit! (logout)) (ts/schedule 100 #(st/emit! (logout)))
;; Conflict ;; Conflict
(= status 412) (= status 412)
(st/emit! (uum/error (tr "errors.conflict"))) (ts/schedule 100 #(st/emit! (uum/error (tr "errors.conflict"))))
;; Network error ;; Network error
(= (:status error) 0) (= (:status error) 0)
(do (ts/schedule 100 #(st/emit! (uum/error (tr "errors.network"))))
(st/emit! (uum/error (tr "errors.network")))
(js/console.error "Stack:" (.-stack error)))
;; Something else ;; Something else
:else :else
(do (ts/schedule 100 #(st/emit! (uum/error (tr "errors.generic"))))))
(st/emit! (uum/error (tr "errors.generic")))
(js/console.error "Stack:" (.-stack error)))))
(set! st/*on-error* on-error) (set! st/*on-error* on-error)

View file

@ -2,7 +2,7 @@
;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;; ;;
;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz> ;; Copyright (c) 2016-2017 Andrey Antukh <niwi@niwi.nz>
(ns uxbox.util.timers) (ns uxbox.util.timers)