0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-02 20:39:09 -05:00

Improve worker error handling

Use the global error handlers for handle
also the worker errors.
This commit is contained in:
Andrey Antukh 2022-03-22 17:24:36 +01:00 committed by Alonso Torres
parent 9582cc0211
commit b87e3c22b3
2 changed files with 9 additions and 9 deletions

View file

@ -7,19 +7,16 @@
(ns app.main.worker (ns app.main.worker
(:require (:require
[app.config :as cfg] [app.config :as cfg]
[app.main.errors :as err]
[app.util.worker :as uw])) [app.util.worker :as uw]))
(defn on-error
[error]
(js/console.error "Error on worker" (pr-str error)))
(defonce instance (atom nil)) (defonce instance (atom nil))
(defn init! (defn init!
[] []
(reset! (reset!
instance instance
(uw/init cfg/worker-uri on-error))) (uw/init cfg/worker-uri err/on-error)))
(defn ask! (defn ask!
[message] [message]

View file

@ -52,10 +52,13 @@
(reply [result] (reply [result]
(post {:payload result})) (post {:payload result}))
(reply-error [err] (reply-error [cause]
(.error js/console "error" (pr-str err)) (if (map? cause)
(post {:error {:data (ex-data err) (post {:error cause})
:message (ex-message err)}})) (post {:error {:type :unexpected
:code :unhandled-error-on-worker
:hint (ex-message cause)
:data (ex-data cause)}})))
(reply-completed (reply-completed
([] (reply-completed nil)) ([] (reply-completed nil))