aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2021-02-05 21:17:55 +0100
committerTeddy Wing2021-02-05 21:17:55 +0100
commite39fea975ff80b622425115f022e239d4a7d61ff (patch)
treee5452a00d838c42defb2239afa30a797ba0501d3
parent64f7b5a7125417b31ca4ab7963d57b38ae663a2f (diff)
downloadextreload-e39fea975ff80b622425115f022e239d4a7d61ff.tar.bz2
main: Exit on uncaught errors and print the message
Previously, we'd drop into the debugger on uncaught errors. Instead, we should just exit with an error message.
-rw-r--r--l/src/main.lisp38
1 files changed, 22 insertions, 16 deletions
diff --git a/l/src/main.lisp b/l/src/main.lisp
index fbe3357..d0ae602 100644
--- a/l/src/main.lisp
+++ b/l/src/main.lisp
@@ -19,22 +19,28 @@
:long "version"))
(defun main ()
- (let ((config (parse-options)))
- ;; Store the WebSocket client as a global.
- (defvar *client* (ws-client config))
-
- ;; TODO: error if no `socket-url`
- (with-websocket-connection (*client*)
- (wsd:on :message *client*
- #'(lambda (message)
- (ws-on-message message (extension-ids config))))
- ; (wsd:on :message *client* #'(lambda (message) (ws-on-message message)))
- ;; TODO: Maybe defvar *config* and store client in the config
-
- (websocket-send *client* (target-get-targets-msg
- (next-call-id *devtools-root-call-id*)))
-
- (wait-group:wait *wg*))))
+ (handler-bind ((error
+ #'(lambda (e)
+ (format *error-output* "error: ~a~%" e)
+
+ (opts:exit 69))))
+
+ (let ((config (parse-options)))
+ ;; Store the WebSocket client as a global.
+ (defvar *client* (ws-client config))
+
+ ;; TODO: error if no `socket-url`
+ (with-websocket-connection (*client*)
+ (wsd:on :message *client*
+ #'(lambda (message)
+ (ws-on-message message (extension-ids config))))
+ ; (wsd:on :message *client* #'(lambda (message) (ws-on-message message)))
+ ;; TODO: Maybe defvar *config* and store client in the config
+
+ (websocket-send *client* (target-get-targets-msg
+ (next-call-id *devtools-root-call-id*)))
+
+ (wait-group:wait *wg*)))))
(defun ws-on-message (message extension-ids)
(let* ((response (jsown:parse message))