Lisp HUG Maillist Archive

need kibitzing re. :top-level-hook usage

I'm trying to suss out how, in a LWW CAPI gui, to (correctly) trap all errors, 
display them, then continue to let the interface run under program control, 
so that the user never has to deal with LW tracebacks / debugger restarts.

I came up with this code, based on invoking the "abort" restart (this function 
is the :top-level-hook for the interface):

(defun hook-editor (func interface) (declare (ignore interface))
    (handler-bind
         ((error
          #'(lambda (c)
              (capi:display-message "~A" c)
              (invoke-restart 'abort))))
      (funcall func)))

This looked like it worked until I added my own condition (internal-abort) and 
tried to signal it at points where I wanted no message at all (i.e. in places 
where the user decides to cancel an operation, I want to abort ("longjmp") 
out of my code back to the top level):

(defun hook-editor (func interface) (declare (ignore interface))
    (handler-bind
        ((internal-abort
          #'(lambda ()
              (invoke-restart 'abort)))
         (error
          #'(lambda (c)
              (capi:display-message "~A" c)
              (invoke-restart 'abort))))
      (funcall func)))

When I (signal 'internal-abort) elsewhere in my code nothing appears to 
happen.

Now I wonder if I'm barking up the wrong tree and not doing this "properly".  
I don't want to destroy the GUI interface and then re-create it (I think), I 
just want to let it keep on running (which is what happens when a user 
manually selects the "abort" restart).

Suggestions most welcome.

thanx
pt


Updated at: 2020-12-10 08:47 UTC