How to catch any JavaScript exception in Clojurescript?

JavascriptWeb DevelopmentFront End Technology

To catch JavaScript exception in Clojurescript, try the following code snippet −

(js/Error. "Oops")
;; throw error

(throw (js/Error. "Error occurred!"))
;; catch error

(try
   (throw (js/Error. "Erro occurred"))
   (catch js/Error e
e))
;; JavaScript allows to throw anything, but handle it with ClojureScript

(try
   (throw (js/Error. "Error Occurred! "))
   (catch :default e
e))
raja
Updated on 23-Jun-2020 06:32:53

Advertisements