From beab8537f4a9deb87495c645dbdb189e16f48d30 Mon Sep 17 00:00:00 2001 From: Ivan Kanakarakis Date: Thu, 10 Sep 2020 01:17:03 +0300 Subject: Use ValueError instead of Exception Signed-off-by: Ivan Kanakarakis --- src/saml2/sigver.py | 2 +- src/saml2/time_util.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/saml2/sigver.py b/src/saml2/sigver.py index 3979d63a..3d744088 100644 --- a/src/saml2/sigver.py +++ b/src/saml2/sigver.py @@ -357,7 +357,7 @@ M2_TIME_FORMAT = '%b %d %H:%M:%S %Y' def to_time(_time): if not _time.endswith(' GMT'): - raise Exception('Time does not end with GMT') + raise ValueError('Time does not end with GMT') _time = _time[:-4] return mktime(str_to_time(_time, M2_TIME_FORMAT)) diff --git a/src/saml2/time_util.py b/src/saml2/time_util.py index b7f1f1cc..332d84bb 100644 --- a/src/saml2/time_util.py +++ b/src/saml2/time_util.py @@ -68,7 +68,7 @@ def parse_duration(duration): else: sign = '+' if duration[index] != "P": - raise Exception('Parse Duration is not valid.') + raise ValueError('Parse Duration is not valid.') index += 1 dic = dict([(typ, 0) for (code, typ) in D_FORMAT if typ]) @@ -77,14 +77,14 @@ def parse_duration(duration): for code, typ in D_FORMAT: #print(duration[index:], code) if duration[index] == '-': - raise Exception("Negation not allowed on individual items") + raise ValueError("Negation not allowed on individual items") if code == "T": if duration[index] == "T": index += 1 if index == len(duration): - raise Exception("Not allowed to end with 'T'") + raise ValueError("Not allowed to end with 'T'") else: - raise Exception("Missing T") + raise ValueError("Missing T") elif duration[index] == "T": continue else: -- cgit v1.2.1