diff options
author | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2020-09-10 01:17:03 +0300 |
---|---|---|
committer | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2020-09-10 01:17:03 +0300 |
commit | beab8537f4a9deb87495c645dbdb189e16f48d30 (patch) | |
tree | b7a746c9e0394aae107d0411ba7618a84402d34d | |
parent | eb4100e8d2865be01877367a5ab03755d71375b5 (diff) | |
download | pysaml2-beab8537f4a9deb87495c645dbdb189e16f48d30.tar.gz |
Use ValueError instead of Exception
Signed-off-by: Ivan Kanakarakis <ivan.kanak@gmail.com>
-rw-r--r-- | src/saml2/sigver.py | 2 | ||||
-rw-r--r-- | 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: |