Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance tracebacks. #477

Merged
merged 1 commit into from
May 15, 2020
Merged

Enhance tracebacks. #477

merged 1 commit into from
May 15, 2020

Conversation

JulienPalard
Copy link
Contributor

Seen a traceback like this:

$ python3 -c 'import jwt; jwt.decode("foo")'
/home/mdk/clones/pyjwt/jwt/api_jwt.py:88: DeprecationWarning: It is strongly recommended that you pass in a value for the "algorithms" argument when calling decode(). This argument will be mandatory in a future version.
  warnings.warn(
Traceback (most recent call last):
  File "/home/mdk/clones/pyjwt/jwt/api_jws.py", line 189, in _load
    signing_input, crypto_segment = jwt.rsplit(b".", 1)
ValueError: not enough values to unpack (expected 2, got 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/mdk/clones/pyjwt/jwt/api_jwt.py", line 95, in decode
    payload, _, _, _ = self._load(jwt)
  File "/home/mdk/clones/pyjwt/jwt/api_jws.py", line 192, in _load
    raise DecodeError("Not enough segments")
jwt.exceptions.DecodeError: Not enough segments

so I just added some raise ... from ... to enhance the message to:

/home/mdk/clones/pyjwt/jwt/api_jwt.py:88: DeprecationWarning: It is strongly recommended that you pass in a value for the "algorithms" argument when calling decode(). This argument will be mandatory in a future version.
  warnings.warn(
Traceback (most recent call last):
  File "/home/mdk/clones/pyjwt/jwt/api_jws.py", line 189, in _load
    signing_input, crypto_segment = jwt.rsplit(b".", 1)
ValueError: not enough values to unpack (expected 2, got 1)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/mdk/clones/pyjwt/jwt/api_jwt.py", line 95, in decode
    payload, _, _, _ = self._load(jwt)
  File "/home/mdk/clones/pyjwt/jwt/api_jws.py", line 192, in _load
    raise DecodeError("Not enough segments") from err
jwt.exceptions.DecodeError: Not enough segments

@coveralls
Copy link

coveralls commented Mar 10, 2020

Pull Request Test Coverage Report for Build 203

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 0.0%

Totals Coverage Status
Change from base Build 132: 0%
Covered Lines: 0
Relevant Lines: 0

💛 - Coveralls

@auvipy auvipy closed this May 15, 2020
@auvipy auvipy reopened this May 15, 2020
Copy link
Collaborator

@auvipy auvipy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Jullen!

@auvipy auvipy merged commit 8556a15 into jpadilla:master May 15, 2020
jpadilla pushed a commit that referenced this pull request Jun 19, 2020
@jpadilla jpadilla added this to the v2.0.0 milestone Dec 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants