Add error logs to API response from GH Service (#7165)

This commit is contained in:
Rohit Malhotra
2025-03-09 17:45:13 -04:00
committed by GitHub
parent 7c2a98d1ce
commit f51eb93d3e

View File

@@ -14,7 +14,7 @@ from openhands.integrations.github.github_types import (
TaskType,
)
from openhands.utils.import_utils import get_impl
from openhands.core.logger import openhands_logger as logger
class GitHubService:
BASE_URL = 'https://api.github.com'
@@ -80,9 +80,12 @@ class GitHubService:
except httpx.HTTPStatusError as e:
if e.response.status_code == 401:
raise GhAuthenticationError('Invalid Github token')
logger.warning(f"Status error on GH API: {e}")
raise GHUnknownException('Unknown error')
except httpx.HTTPError:
except httpx.HTTPError as e:
logger.warning(f"HTTP error on GH API: {e}")
raise GHUnknownException('Unknown error')
async def get_user(self) -> GitHubUser:
@@ -174,9 +177,12 @@ class GitHubService:
except httpx.HTTPStatusError as e:
if e.response.status_code == 401:
raise GhAuthenticationError('Invalid Github token')
logger.warning(f"Status error on GH API: {e}")
raise GHUnknownException('Unknown error')
except httpx.HTTPError:
except httpx.HTTPError as e:
logger.warning(f"HTTP error on GH API: {e}")
raise GHUnknownException('Unknown error')
async def get_suggested_tasks(self) -> list[SuggestedTask]: