aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2019-08-15 20:51:53 +0100
committerJuan J. Martinez <jjm@usebox.net>2019-08-15 20:51:53 +0100
commite0610ce140f9f0d083d3e93e6557073316c05bb7 (patch)
treed8e64094d9e218eacb97579b94b6b42226d6722e
parent07aaa73ada89cac2436dd4f76f2be3ed4870a337 (diff)
downloadz80count-e0610ce140f9f0d083d3e93e6557073316c05bb7.tar.gz
z80count-e0610ce140f9f0d083d3e93e6557073316c05bb7.zip
Make errors a bit more user friendly
-rw-r--r--z80count/z80count.py11
1 files 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