From de7c1f76db1c26eb514a435a04a07a884c320d3b Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 30 Sep 2018 12:32:13 -0400 Subject: [PATCH] gcode_macro: Provide more information on a formatting error Signed-off-by: Kevin O'Connor --- klippy/extras/gcode_macro.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/klippy/extras/gcode_macro.py b/klippy/extras/gcode_macro.py index 7fe4bfed..3818df7e 100644 --- a/klippy/extras/gcode_macro.py +++ b/klippy/extras/gcode_macro.py @@ -3,7 +3,7 @@ # Copyright (C) 2018 Kevin O'Connor # # This file may be distributed under the terms of the GNU GPLv3 license. -import logging +import traceback, logging DEFAULT_PREFIX = 'default_parameter_' @@ -31,8 +31,9 @@ class GCodeMacro: kwparams.update(params) try: script = self.script.format(**kwparams) - except Exception: - msg = "Macro %s script formatting failed" % (self.alias,) + except Exception as e: + msg = "Error evaluating %s: %s" % ( + self.alias, traceback.format_exception_only(type(e), e)[-1]) logging.exception(msg) raise self.gcode.error(msg) self.in_script = True