Added basic exception handler.

This commit is contained in:
Julien Eluard 2017-07-17 00:23:53 +02:00 committed by Roman Volosovskyi
parent 63d9301a27
commit 614a2d89cb
3 changed files with 19 additions and 2 deletions

View File

@ -47,7 +47,8 @@
[status-im.components.status :as status]
[status-im.components.styles :as st]
[status-im.chat.styles.screen :as chat-st]
[status-im.profile.qr-code.screen :refer [qr-code-view]]))
[status-im.profile.qr-code.screen :refer [qr-code-view]]
[status-im.utils.utils :as utils]))
(defn init-back-button-handler! []
(let [new-listener (fn []
@ -166,6 +167,7 @@
[component])]])]]))))})))
(defn init []
(utils/register-exception-handler)
(status/call-module status/init-jail)
(dispatch-sync [:reset-app])
(.registerComponent app-registry "StatusIm" #(r/reactify-component app-root))

View File

@ -43,7 +43,8 @@
[taoensso.timbre :as log]
[status-im.chat.styles.screen :as st]
[status-im.profile.qr-code.screen :refer [qr-code-view]]
[status-im.components.status :as status]))
[status-im.components.status :as status]
[status-im.utils.utils :as utils]))
(defn orientation->keyword [o]
(keyword (.toLowerCase o)))
@ -137,6 +138,7 @@
[component])]])]))))})))
(defn init []
(utils/register-exception-handler)
(status/call-module status/init-jail)
(dispatch-sync [:reset-app])
(dispatch [:listen-to-network-status!])

View File

@ -116,3 +116,16 @@
(apply update m k f args)
m))
(defn default-alert-handler
[error fatal?]
(show-popup "Error" (.-message error)))
(defn register-exception-handler
"Register a function that will be called for each exception thrown.
When `dev?` is true, always register; otherwise only register when goog.DEBUG is false.
Default function shows error details in an alert box."
([] (register-exception-handler default-alert-handler))
([f] (register-exception-handler true f))
([dev? f]
(if (or dev? (not js/goog.DEBUG))
(.setGlobalHandler js/ErrorUtils f dev?))))