From 83788f5c08648cdb8e03827611a7d71eb5123a65 Mon Sep 17 00:00:00 2001 From: Raphael Bauduin Date: Tue, 26 May 2015 10:44:34 -0700 Subject: [PATCH] handle exceptions --- src/mpValidations.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/mpValidations.py b/src/mpValidations.py index 804c242..aa53fd7 100644 --- a/src/mpValidations.py +++ b/src/mpValidations.py @@ -71,11 +71,14 @@ class TcptraceTest: klass_name=val["name"].title().replace("_","")+"Validation" tester_klass=globals()[klass_name] tester = tester_klass(val) - if tester.validate(tested_value): - self.logs=self.logs+ ("" if self.logs=="" else "\n ")+ " -" +tester.name()+" OK\n" - else: - self.logs=self.logs+ ("" if self.logs=="" else "\n ")+ " -" +tester.name()+" FAILS "+ val["desc"] +"\n" - is_ok = False + try: + if tester.validate(tested_value): + self.logs=self.logs+ ("" if self.logs=="" else "\n ")+ " -" +tester.name()+" OK\n" + else: + self.logs=self.logs+ ("" if self.logs=="" else "\n ")+ " -" +tester.name()+" FAILS "+ val["desc"] +"\n" + is_ok = False + except Exception as e: + self.logs=self.logs+ ("" if self.logs=="" else "\n ")+ " -" +tester.name()+" FAILS (EXCEPTION:"+ str(e) + ") "+ val["desc"] +"\n" return is_ok def name(self): return self.__class__.__name__