From ee8513ebecd7dddecd3cc33715e7746e9b2d67e3 Mon Sep 17 00:00:00 2001 From: Almarhoon Ibraheem Date: Sat, 22 Jun 2024 14:03:48 +0300 Subject: [PATCH] handle and log exceptions from general commander --- modules/general.scm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/general.scm b/modules/general.scm index a641799..7d35741 100755 --- a/modules/general.scm +++ b/modules/general.scm @@ -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)))