fix: clean error messages for expected API and OAuth failures#41
Merged
Conversation
handle_api_error keeps re-raising unknown errors so command-specific handlers can add context. A new CLI boundary (main.cli) turns any HttpError/OAuth2Error that reaches the top into a single clean line, and _authenticate_local_server catches OAuth denial during login. Closes #38
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #41 +/- ##
==========================================
+ Coverage 83.60% 83.81% +0.21%
==========================================
Files 15 15
Lines 2427 2447 +20
Branches 356 354 -2
==========================================
+ Hits 2029 2051 +22
+ Misses 265 264 -1
+ Partials 133 132 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #38
Problem
Expected, user-facing failures dumped a full Rich traceback: any non-403
HttpError(e.g. a 400 fromanalytics querywith an unaligned date range) and OAuth denial duringytstudio login.Fix
handle_api_errorkeeps re-raising unknown errors so command-specific handlers (comments, livestreams) can still add context.main.cli(now theytstudio/ytsentry point) turns anyHttpError/OAuth2Errorthat reaches the top into a single clean line + exit 1. Unexpected exceptions keep their traceback._authenticate_local_servercatchesAccessDeniedError/OAuth2Errorduring login with a friendly hint.Tests
Added coverage for the boundary (clean message, no traceback) and OAuth denial. Full suite: 287 passed, ruff clean.