Skip to content

Commit 2221cb6

Browse files
committed
Rename InvalidToken exception to InvalidTokenError
...as discussed in jpadilla#60.
1 parent e3f0ce0 commit 2221cb6

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ You can still get the payload by setting the `verify` argument to `False`.
4343
jwt.decode('someJWTstring', verify=False)
4444
```
4545

46-
The `decode()` function can raise other exceptions, e.g. for invalid issuer or audience (see below). All exceptions that signify that the token is invalid extend from the base `InvalidToken` exception class, so applications can use this approach to catch any issues relating to invalid tokens:
46+
The `decode()` function can raise other exceptions, e.g. for invalid issuer or audience (see below). All exceptions that signify that the token is invalid extend from the base `InvalidTokenError` exception class, so applications can use this approach to catch any issues relating to invalid tokens:
4747

4848
```python
4949
try:
5050
payload = jwt.decode('someJWTstring')
51-
exception jwt.InvalidToken:
51+
exception jwt.InvalidTokenError:
5252
pass # do something sensible here, e.g. return HTTP 403 status code
5353
```
5454

jwt/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,28 @@
2828

2929
__version__ = '0.4.0'
3030
__all__ = [
31-
'encode', 'decode', 'InvalidToken', 'DecodeError',
31+
'encode', 'decode', 'InvalidTokenError', 'DecodeError',
3232
'ExpiredSignature', 'InvalidAudience', 'InvalidIssuer'
3333
]
3434

3535

36-
class InvalidToken(Exception):
36+
class InvalidTokenError(Exception):
3737
pass
3838

3939

40-
class DecodeError(InvalidToken):
40+
class DecodeError(InvalidTokenError):
4141
pass
4242

4343

44-
class ExpiredSignature(InvalidToken):
44+
class ExpiredSignature(InvalidTokenError):
4545
pass
4646

4747

48-
class InvalidAudience(InvalidToken):
48+
class InvalidAudience(InvalidTokenError):
4949
pass
5050

5151

52-
class InvalidIssuer(InvalidToken):
52+
class InvalidIssuer(InvalidTokenError):
5353
pass
5454

5555

0 commit comments

Comments
 (0)