Skip to content

Feature: Add __str__ to OAuthRefreshException#107

Merged
glensc merged 1 commit into
mainfrom
OAuthRefreshException-__str__
Jun 1, 2026
Merged

Feature: Add __str__ to OAuthRefreshException#107
glensc merged 1 commit into
mainfrom
OAuthRefreshException-__str__

Conversation

@glensc
Copy link
Copy Markdown
Owner

@glensc glensc commented May 28, 2026

Extracted from #104

Adds a __str__ method to OAuthRefreshException so stringifying the exception produces a more descriptive message that includes the error and error_description fields from the OAuth response when available, falling back to the inherited message.

Changes:

  • Implement __str__ on OAuthRefreshException with three formatting branches (both fields, error only, message only).

@glensc glensc self-assigned this May 28, 2026
@glensc glensc requested a review from Copilot May 28, 2026 16:12
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Review Change Stack

Walkthrough

The OAuthRefreshException.__str__ method is enhanced to provide more detailed error messages. When both error and error_description fields are available, both are included in the output; when only error is present, it is included; otherwise the base message is used as a fallback.

Changes

OAuth Error Message Formatting

Layer / File(s) Summary
Enhanced error message formatting
trakt/errors.py
OAuthRefreshException.__str__ updated with conditional logic to include both error and error_description fields when available, or fall back to the error field alone, or default to the base message.

Possibly related PRs

  • glensc/python-pytrakt#106: Both PRs modify OAuthRefreshException error messaging in trakt/errors.py to provide more OAuth refresh failure details.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A rabbit hops through error streams,
With messages now rich and keen,
Both fields dancing, hand in hand,
Details bloom across the land,
Errors clearer—oh, how grand! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main change—adding a str method to OAuthRefreshException class.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description clearly relates to the changeset, detailing the addition of a str method to OAuthRefreshException with specific formatting logic.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch OAuthRefreshException-__str__

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a __str__ method to OAuthRefreshException so stringifying the exception produces a more descriptive message that includes the error and error_description fields from the OAuth response when available, falling back to the inherited message.

Changes:

  • Implement __str__ on OAuthRefreshException with three formatting branches (both fields, error only, message only).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread trakt/errors.py
Comment thread trakt/errors.py
Comment thread trakt/errors.py
@glensc glensc force-pushed the OAuthRefreshException-__str__ branch from 18149c1 to 3aeaedf Compare June 1, 2026 10:38
@glensc glensc requested a review from Copilot June 1, 2026 10:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread trakt/errors.py
Comment on lines +112 to +119
def __str__(self):
if self.error and self.error_description:
return f'{self.message}: {self.error} - {self.error_description}'

if self.error:
return f'{self.message}: {self.error}'

return self.message
@glensc glensc merged commit 3cd59e5 into main Jun 1, 2026
9 checks passed
@glensc glensc deleted the OAuthRefreshException-__str__ branch June 1, 2026 10:47
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.

2 participants