handle errors from jail

This commit is contained in:
Roman Volosovskyi 2016-06-23 19:07:31 +03:00
parent d07688136f
commit 40dd0063d2
4 changed files with 39 additions and 24 deletions

View File

@ -133,7 +133,7 @@ dependencies {
compile project(':react-native-camera')
compile project(':react-native-status')
compile project(':react-native-orientation')
compile(group: 'status-im', name: 'status-go', version: '0.1.0-201606220917-ec4b9a', ext: 'aar')
compile(group: 'status-im', name: 'status-go', version: '0.1.0-201606231357-85abe1', ext: 'aar')
compile fileTree(dir: "node_modules/realm/android/libs", include: ["*.jar"])
}

View File

@ -85,7 +85,9 @@
(defn container-animation-logic [{:keys [to-value val]}]
(fn [_]
(let [to-value @to-value]
(anim/start (anim/spring val {:toValue to-value})))))
(anim/start (anim/spring val {:toValue to-value
:tension 50
:friction 10})))))
(defn container [response-height & children]
(let [;; todo to-response-height, cur-response-height must be specific

View File

@ -26,19 +26,30 @@
(def regular-events {})
(defn command-nadler!
[_ [{:keys [to]} response]]
(let [{:keys [event params]} (json->cljs response)
events (if (= "console" to)
(merge regular-events console-events)
regular-events)]
(when-let [handler (events (keyword event))]
(apply handler params))))
(defn print-error! [error]
(toast error)
(println error))
(defn suggestions-handler
(defn command-hadler!
[_ [{:keys [to] :as command} response]]
(let [{:keys [error result]} (json->cljs response)]
(if error
(let [m (str "Error on command handling!\n" command error)]
(print-error! m))
(let [{:keys [event params]} result
events (if (= "console" to)
(merge regular-events console-events)
regular-events)]
(when-let [handler (events (keyword event))]
(apply handler params))))))
(defn suggestions-handler!
[db [{:keys [chat-id]} response-json]]
(let [response (json->cljs response-json)]
(assoc-in db [:suggestions chat-id] (generate-hiccup response))))
(let [{:keys [error result]} (json->cljs response-json)]
(when error
(let [m (str "Error on param suggestions!\n" error)]
(print-error! m)))
(assoc-in db [:suggestions chat-id] (generate-hiccup result))))
(defn suggestions-events-handler!
[db [[n data]]]
@ -62,9 +73,9 @@
(reg-handler :init-render-command! init-render-command!)
(reg-handler ::render-command render-command)
(reg-handler :command-handler! (u/side-effect! command-nadler!))
(reg-handler :command-handler! (u/side-effect! command-hadler!))
(reg-handler :suggestions-handler
(after #(dispatch [:animate-show-response]))
suggestions-handler)
suggestions-handler!)
(reg-handler :suggestions-event! (u/side-effect! suggestions-events-handler!))
(reg-handler :command-preview command-preview)

View File

@ -44,10 +44,10 @@
(defn parse-commands! [_ [identity file]]
(j/parse identity file
(fn [result]
(let [commands (json->cljs result)]
;; todo use commands from jail
(dispatch [::add-commands identity file commands])))
#_(dispatch [::loading-failed! identity ::error-in-jail %])))
(let [{:keys [error result]} (json->cljs result)]
(if error
(dispatch [::loading-failed! identity ::error-in-jail error])
(dispatch [::add-commands identity file result]))))))
(defn validate-hash
[db [identity file]]
@ -70,11 +70,13 @@
(defn loading-failed!
[db [id reason details]]
(let [url (get-in db [:chats id :dapp-url])]
(toast (s/join "\n" ["commands.js loading failed"
url
id
(name reason)
details]))))
(let [m (s/join "\n" ["commands.js loading failed"
url
id
(name reason)
details])]
(toast m)
(println m))))
(reg-handler :load-commands! (u/side-effect! load-commands!))
(reg-handler ::fetch-commands! (u/side-effect! fetch-commands!))