From a1c143d6747d2136dd7eb21478e13fc95e1c8efc Mon Sep 17 00:00:00 2001 From: Gregory Ashton <gregory.ashton@ligo.org> Date: Mon, 6 May 2019 17:52:18 -0500 Subject: [PATCH] Improve the warning message when reading a prior-file fails --- bilby/core/prior.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bilby/core/prior.py b/bilby/core/prior.py index 5e6894e74..aca8e710e 100644 --- a/bilby/core/prior.py +++ b/bilby/core/prior.py @@ -115,7 +115,12 @@ class PriorDict(OrderedDict): elements = line.split('=') key = elements[0].replace(' ', '') val = '='.join(elements[1:]) - prior[key] = eval(val) + try: + prior[key] = eval(val) + except TypeError as e: + raise TypeError( + "Unable to parse dictionary file {}, bad line: {} = {}. Error message {}" + .format(filename, key, val, e)) self.update(prior) def from_dictionary(self, dictionary): -- GitLab