From e39fea975ff80b622425115f022e239d4a7d61ff Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Fri, 5 Feb 2021 21:17:55 +0100 Subject: 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. --- l/src/main.lisp | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'l/src/main.lisp') 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)) -- cgit v1.2.3