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"
(*verbose-output* variable)
(*break-on-error* variable)
(initialize function)
(shutdown-clog function)
@ -74,6 +75,7 @@ script."
#-(or sbcl ecl mezzano) (apply #'make-hash-table args))
(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 *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")
;;;;;;;;;;;;;;;;;
;; generate-id ;;
;;;;;;;;;;;;;;;;;
@ -178,11 +181,13 @@ the default answer. (Private)"
(format nil "clog['connection_id']=~A" id))
(bordeaux-threads:make-thread
(lambda ()
(handler-case
(if *break-on-error*
(funcall *on-connect-handler* id)
(t (c)
(format t "Condition caught connection ~A - ~A.~&" id c)
(values 0 c))))
(handler-case
(funcall *on-connect-handler* id)
(t (c)
(format t "Condition caught connection ~A - ~A.~&" id c)
(values 0 c)))))
:name (format nil "CLOG connection ~A"
id))))
(t (c)
@ -210,15 +215,21 @@ the default answer. (Private)"
id event-id data))
(bordeaux-threads:make-thread
(lambda ()
(handler-case
(if *break-on-error*
(let* ((event-hash (get-connection-data id))
(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))))
(handler-case
(let* ((event-hash (get-connection-data id))
(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"
event-id))))
(t