mirror of
https://github.com/ebeem/guile-swayer.git
synced 2024-11-16 07:47:32 +01:00
handle and log exceptions from general commander
This commit is contained in:
parent
672beab59b
commit
ee8513ebec
1 changed files with 8 additions and 3 deletions
|
@ -183,10 +183,15 @@ For example:
|
|||
|
||||
(define (custom-exception-handler exc command-id payload)
|
||||
"Exception handler for evaluating expressions from commander."
|
||||
(format #t "An error occurd while executing the expression: ~a\n" (exp->string exc))
|
||||
(format #t "command: ~a, payload: ~a\n" command-id payload))
|
||||
(format #t "An error occurd while executing the received
|
||||
general command: command: ~a, payload: ~a\n" command-id payload)
|
||||
(format #t "exception: ~a\n" exc))
|
||||
|
||||
;; add a hook to listen to received commands (usually from commander)
|
||||
(add-hook! command-received-hook
|
||||
(lambda (command-id payload)
|
||||
(eval-string (json-string->scm payload))))
|
||||
(with-exception-handler
|
||||
(lambda (exc)
|
||||
(custom-exception-handler exc command-id payload))
|
||||
(lambda () (eval-string (json-string->scm payload)))
|
||||
#:unwind? #t)))
|
||||
|
|
Loading…
Reference in a new issue