From f6f7c26e115c61153017b50660d0561f854a8e20 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Mon, 13 May 2019 19:22:24 +0000 Subject: [PATCH] Safely log when a command error cannot be sent If a command triggers an error back to the user and sending that error raises an exception, log it and continue to avoid crashing the engine. --- mudpy/command.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mudpy/command.py b/mudpy/command.py index 2b20b1a..39e0a83 100644 --- a/mudpy/command.py +++ b/mudpy/command.py @@ -6,6 +6,7 @@ import random import re +import traceback import unicodedata import mudpy @@ -117,8 +118,13 @@ def error(actor, input_data): else: message = "Arglebargle, glop-glyf!?!" - # send the error message - actor.send(message) + # try to send the error message, and log if we can't + try: + actor.send(message) + except Exception: + mudpy.misc.log( + 'Sending a command error to user %s raised exception...\n%s' % ( + actor.owner.account.get("name"), traceback.format_exc())) def halt(actor, parameters): -- 2.11.0