From 55f7cbb1bbd8cfc87608c98beb0516f533674c9a Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sun, 23 Dec 2018 20:24:05 +0200 Subject: [PATCH] Include command error traceback for admins --- mautrix_telegram/commands/handler.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mautrix_telegram/commands/handler.py b/mautrix_telegram/commands/handler.py index 3cad49b4..411ab686 100644 --- a/mautrix_telegram/commands/handler.py +++ b/mautrix_telegram/commands/handler.py @@ -15,9 +15,11 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . from typing import Awaitable, Callable, Dict, List, NamedTuple, Optional -import commonmark +import traceback import logging +import commonmark + from telethon.errors import FloodWaitError from ..types import MatrixRoomID @@ -194,6 +196,11 @@ class CommandProcessor: except Exception: self.log.exception("Unhandled error while handling command " f"{evt.command} {' '.join(args)} from {sender.mxid}") + if evt.sender.is_admin and evt.is_management: + return await evt.reply("Unhandled error while handling command:\n\n" + "```traceback\n" + f"{traceback.format_exc()}" + "```") return await evt.reply("Unhandled error while handling command. " "Check logs for more details.") return None