Skip to content

Commit

Permalink
verify that exception data is serializable
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruce Hauman committed Apr 26, 2018
1 parent 0136c9a commit 9a91b8b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
18 changes: 12 additions & 6 deletions figwheel-core/src/figwheel/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -600,12 +600,18 @@
;; -------------------------------------------------------------

(defn exception-code [parsed-exception]
(format "figwheel.core.handle_exception_remote(%s);"
(json/write-str
(-> parsed-exception
(update :tag #(string/join "/" ((juxt namespace name) %)))
pr-str
edn/read-string))))
(let [parsable-data?
(try (some-> parsed-exception :data pr-str edn/read-string)
(catch Throwable t
false))
parsed-exception' (cond-> parsed-exception
(not parsable-data?) (dissoc :data))]
(format "figwheel.core.handle_exception_remote(%s);"
(json/write-str
(-> parsed-exception'
(update :tag #(string/join "/" ((juxt namespace name) %)))
pr-str
edn/read-string)))))

(defn handle-exception [exception-o-throwable-map]
(let [{:keys [file line] :as parsed-ex} (fig-ex/parse-exception exception-o-throwable-map)
Expand Down
3 changes: 2 additions & 1 deletion figwheel-core/src/figwheel/tools/exceptions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,12 @@
(defmethod data :default [tm]
(or (:data tm) (->> tm :via reverse (keep :data) first)))

(defmethod data :clj/spec-based-syntax-error [tm] nil)
#_(defmethod data :clj/spec-based-syntax-error [tm] nil)

(defn ex-type [tm]
(some-> tm :via last :type pr-str symbol))


(defn parse-exception [e]
(let [tm (if (instance? Throwable e) (Throwable->map e) e)
tag (exception-type? tm)
Expand Down

0 comments on commit 9a91b8b

Please sign in to comment.