atlas-engineer / cl-electron

Lisp Interface to Electron.
BSD 3-Clause "New" or "Revised" License
16 stars 1 forks source link

Gracefully handle errors on `execute-javascript-synchronous` #30

Closed aadcg closed 6 months ago

aadcg commented 6 months ago

To reproduce, run electron/demos::electron-views-demo with the changes below and notice that it never returns.

modified   demos/demo-views.lisp
@@ -27,7 +27,7 @@ defmethod initialize-instance
                      (lambda (web-contents) (setf (url main-view) (electron:get-url web-contents))))
   (electron:load-url main-view "https://en.wikipedia.org/wiki/Electron")
   (print (electron:execute-javascript-synchronous (electron:web-contents main-view)
-                                                  "1 + 1")))
+                                                  "bogus")))

 (define-class modeline (browser-view-bound-to-window) ())

The expected behavior is to catch the error as below.

> (electron::send-message-interface electron:*interface* "bogus")
"ReferenceError: bogus is not defined"
NIL
jmercouris commented 6 months ago

We cannot return the ReferenceError, this is a limitation of Electron.

https://github.com/electron/electron/pull/18635 https://github.com/electron/electron/issues/9102