From faa7846155a3c31d2b23bff23fc91dfc37d41d82 Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Mon, 8 Mar 2021 09:39:34 +0100 Subject: [PATCH] give action errors more context --- dotdrop/action.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/dotdrop/action.py b/dotdrop/action.py index b0c0177..57f9978 100644 --- a/dotdrop/action.py +++ b/dotdrop/action.py @@ -36,7 +36,7 @@ class Cmd(DictParser): try: action = templater.generate_string(self.action) except UndefinedException as e: - err = 'bad {}: {}'.format(self.descr, e) + err = 'undefined variable for {}: \"{}\"'.format(self.descr, e) self.log.warn(err) return False if debug: @@ -51,8 +51,8 @@ class Cmd(DictParser): try: args = [templater.generate_string(a) for a in args] except UndefinedException as e: - err = 'bad arguments for {}: {}'.format(self.descr, e) - self.log.warn(err) + err = 'undefined arguments for {}: {}' + self.log.warn(err.format(self.descr, e)) return False if debug and args: self.log.dbg('action args:') @@ -60,13 +60,14 @@ class Cmd(DictParser): self.log.dbg('\targs[{}]: {}'.format(cnt, arg)) try: cmd = action.format(*args) - except IndexError: - err = 'bad {}: \"{}\"'.format(self.descr, action) + except IndexError as e: + err = 'index error for {}: \"{}\"'.format(self.descr, action) err += ' with \"{}\"'.format(args) + err += ': {}'.format(e) self.log.warn(err) return False - except KeyError: - err = 'bad {}: \"{}\"'.format(self.descr, action) + except KeyError as e: + err = 'key error for {}: \"{}\": {}'.format(self.descr, action, e) err += ' with \"{}\"'.format(args) self.log.warn(err) return False