diff options
| author | Simeon Simeonov | 2020-12-04 12:36:58 +0100 |
|---|---|---|
| committer | Simeon Simeonov | 2020-12-04 12:36:58 +0100 |
| commit | 7498bf51d85f98d67d72193dc01db2afb83aeaf3 (patch) | |
| tree | f92f504d3d056dbb09e10c63f06e17201d2b76f1 /otp2289/server.py | |
| parent | c1378156e2ae02c37d0b19b033cad20f72bcd37d (diff) | |
Raise exceptions from except properly
Diffstat (limited to 'otp2289/server.py')
| -rw-r--r-- | otp2289/server.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/otp2289/server.py b/otp2289/server.py index 7322727..d0c3e01 100644 --- a/otp2289/server.py +++ b/otp2289/server.py | |||
| @@ -79,7 +79,7 @@ class OTPState: | |||
| 79 | self._hash_algo = OTPGenerator.validate_hash_algo(hash_algo) | 79 | self._hash_algo = OTPGenerator.validate_hash_algo(hash_algo) |
| 80 | self._step = OTPGenerator.validate_step(current_step) | 80 | self._step = OTPGenerator.validate_step(current_step) |
| 81 | except OTPGeneratorException as exp: | 81 | except OTPGeneratorException as exp: |
| 82 | raise OTPStateException(exp.args[0]) | 82 | raise OTPStateException(exp.args[0]) from None |
| 83 | self._current_digest = None | 83 | self._current_digest = None |
| 84 | if ot_hex is not None: | 84 | if ot_hex is not None: |
| 85 | self._current_digest = self.validate_hex(ot_hex) | 85 | self._current_digest = self.validate_hex(ot_hex) |
| @@ -166,7 +166,7 @@ class OTPState: | |||
| 166 | return OTPState.validate_hex(response) | 166 | return OTPState.validate_hex(response) |
| 167 | except OTPStateException: | 167 | except OTPStateException: |
| 168 | raise OTPInvalidResponse( | 168 | raise OTPInvalidResponse( |
| 169 | 'The response is neither a valid token or hex') | 169 | 'The response is neither a valid token or hex') from None |
| 170 | 170 | ||
| 171 | @staticmethod | 171 | @staticmethod |
| 172 | def validate_hex(ot_hex): | 172 | def validate_hex(ot_hex): |
| @@ -192,7 +192,7 @@ class OTPState: | |||
| 192 | try: | 192 | try: |
| 193 | return binascii.unhexlify(ot_hex) | 193 | return binascii.unhexlify(ot_hex) |
| 194 | except binascii.Error: | 194 | except binascii.Error: |
| 195 | raise OTPStateException('Invalid OT-hex') | 195 | raise OTPStateException('Invalid OT-hex') from None |
| 196 | 196 | ||
| 197 | def get_next_state(self): | 197 | def get_next_state(self): |
| 198 | """ | 198 | """ |
