From e0610ce140f9f0d083d3e93e6557073316c05bb7 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Thu, 15 Aug 2019 20:51:53 +0100 Subject: Make errors a bit more user friendly --- z80count/z80count.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/z80count/z80count.py b/z80count/z80count.py index f274139..5714c28 100644 --- a/z80count/z80count.py +++ b/z80count/z80count.py @@ -40,9 +40,9 @@ DEF_CONFIG_FILE = "z80countrc" def perror(message, *args, **kwargs): exc = kwargs.get("exc") - print(message % args, file=sys.stderr) if exc: - print(str(exc)) + print(exc, file=sys.stderr) + print(message % args, file=sys.stderr) ########################################################################## @@ -112,8 +112,8 @@ def load_config_file(config_file, schema): parser["z80count"] = {i.config_name: i.default for i in schema} try: parser.read(config_file) - except configparser.Error as e: - perror("Error parsing config file. Using defaults.", exc=e) + except configparser.Error as ex: + perror("Error parsing config file. Using defaults.", exc=ex) section = parser["z80count"] res = {} @@ -121,11 +121,10 @@ def load_config_file(config_file, schema): v = section.get(opt.config_name) try: v = opt.type(v) - except (ValueError, TypeError) as e: + except (ValueError, TypeError): perror( "Error parsing config value for '%s'. Using default.", opt.config_name, - exc=e, ) v = opt.default res[opt.config_name] = v -- cgit v1.2.3