From: Tim Vaughan Date: Sat, 1 May 2021 21:40:13 +0000 (+0200) Subject: Message delivery now catches exceptions and prints warning. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=sam.git;a=commitdiff_plain;h=7a4abf91e47b6115f8ad006b9b1a5653894a115e Message delivery now catches exceptions and prints warning. --- diff --git a/sam.scm b/sam.scm index ed69987..8f2741f 100644 --- a/sam.scm +++ b/sam.scm @@ -77,12 +77,15 @@ (let ((id (address-id address))) (let ((behaviour (hash-table-ref/default actor-table id '()))) (if (null? behaviour) - (print "Warning: discarded message " message + (print "## Warning: discarded message " message " to unknown actor id " id) - (match (apply (hash-table-ref actor-table id) (cons address message)) - ('done (hash-table-delete! actor-table id)) - ('sleep 'do-nothing) - (new-beh (hash-table-set! actor-table id new-beh))))))) + (condition-case + (match (apply behaviour (cons address message)) + ('done (hash-table-delete! actor-table id)) + ('sleep 'do-nothing) + (new-beh (hash-table-set! actor-table id new-beh))) + ((exn) + (print "## Warning: actor id " id " crashed evaluating message " message))))))) ;; Scheduler