Restore improved exception handling and update test for specific httpx.HTTPStatusError

- Use httpx.HTTPStatusError for more specific exception catching
- Provide better error message: 'GitHub token validation failed. Please check your token and try again.'
- Update test to expect improved error message and properly mock httpx exceptions
This commit is contained in:
ehhuang 2025-07-08 01:22:42 -07:00
parent 871021adc4
commit 7f4d55f5f7
2 changed files with 7 additions and 4 deletions

View file

@ -328,9 +328,9 @@ class GitHubTokenAuthProvider(AuthProvider):
"""
try:
user_info = await _get_github_user_info(token, self.config.github_api_base_url)
except Exception as e:
except httpx.HTTPStatusError as e:
logger.warning(f"GitHub token validation failed: {e}")
raise ValueError("Invalid GitHub token") from e
raise ValueError("GitHub token validation failed. Please check your token and try again.") from e
principal = user_info["user"]["login"]