Skip to content

Commit

Permalink
Fix catch-exception on cljs
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkerlucio committed Dec 13, 2024
1 parent bfc56ae commit b153236
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions test/com/wsscode/pathom3/test/helpers.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,18 @@
x))
x))

(defmacro catch-exception [& body]
`(try
~@body
(catch #?(:clj Throwable :cljs :default) e#
{:ex/message (ex-message e#)
:ex/data (ex-data e#)})))
(defn error->data [error]
{:ex/message (ex-message error)
:ex/data (ex-data error)})

#?(:clj
(defmacro catch-exception [& body]
(if (:ns &env)
`(try
~@body
(catch :default e#
(error->data e#)))
`(try
~@body
(catch Throwable e#
(error->data e#))))))

0 comments on commit b153236

Please sign in to comment.