configurable break on exceptions

This commit is contained in:
David Botton 2022-04-05 13:49:58 -04:00
parent fa5f2d9e7c
commit 46394d7ec1

View file

@ -34,6 +34,7 @@ script."
"CLOG system startup and shutdown" "CLOG system startup and shutdown"
(*verbose-output* variable) (*verbose-output* variable)
(*break-on-error* variable)
(initialize function) (initialize function)
(shutdown-clog function) (shutdown-clog function)
@ -74,6 +75,7 @@ script."
#-(or sbcl ecl mezzano) (apply #'make-hash-table args)) #-(or sbcl ecl mezzano) (apply #'make-hash-table args))
(defvar *verbose-output* nil "Verbose server output (default false)") (defvar *verbose-output* nil "Verbose server output (default false)")
(defvar *break-on-error* t "Allow invoking debugger (default true)")
(defvar *app* nil "Clack 'app' middle-ware") (defvar *app* nil "Clack 'app' middle-ware")
(defvar *client-handler* nil "Clack 'handler' for socket traffic") (defvar *client-handler* nil "Clack 'handler' for socket traffic")
@ -95,6 +97,7 @@ script."
(defvar *url-to-boot-file* (make-hash-table* :test 'equalp) "URL to boot-file") (defvar *url-to-boot-file* (make-hash-table* :test 'equalp) "URL to boot-file")
;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;
;; generate-id ;; ;; generate-id ;;
;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;
@ -178,11 +181,13 @@ the default answer. (Private)"
(format nil "clog['connection_id']=~A" id)) (format nil "clog['connection_id']=~A" id))
(bordeaux-threads:make-thread (bordeaux-threads:make-thread
(lambda () (lambda ()
(handler-case (if *break-on-error*
(funcall *on-connect-handler* id) (funcall *on-connect-handler* id)
(t (c) (handler-case
(format t "Condition caught connection ~A - ~A.~&" id c) (funcall *on-connect-handler* id)
(values 0 c)))) (t (c)
(format t "Condition caught connection ~A - ~A.~&" id c)
(values 0 c)))))
:name (format nil "CLOG connection ~A" :name (format nil "CLOG connection ~A"
id)))) id))))
(t (c) (t (c)
@ -210,15 +215,21 @@ the default answer. (Private)"
id event-id data)) id event-id data))
(bordeaux-threads:make-thread (bordeaux-threads:make-thread
(lambda () (lambda ()
(handler-case (if *break-on-error*
(let* ((event-hash (get-connection-data id)) (let* ((event-hash (get-connection-data id))
(event (when event-hash (event (when event-hash
(gethash event-id event-hash)))) (gethash event-id event-hash))))
(when event (when event
(funcall event data))) (funcall event data)))
(t (c) (handler-case
(format t "Condition caught in handle-message for event - ~A.~&" c) (let* ((event-hash (get-connection-data id))
(values 0 c)))) (event (when event-hash
(gethash event-id event-hash))))
(when event
(funcall event data)))
(t (c)
(format t "Condition caught in handle-message for event - ~A.~&" c)
(values 0 c)))))
:name (format nil "CLOG event handler ~A" :name (format nil "CLOG event handler ~A"
event-id)))) event-id))))
(t (t