Skip to content
Snippets Groups Projects
Commit 8017ebd3 authored by Tulir Asokan's avatar Tulir Asokan :cat2:
Browse files

Fix parsing error responses

parent 79bfdd7f
No related branches found
No related tags found
No related merge requests found
Pipeline #16160 passed
......@@ -28,10 +28,10 @@ OptStrList = Optional[List[str]]
class GitHubError(Exception):
def __init__(self, message: str, documentation_url: str, status: int, **kwargs) -> None:
def __init__(self, message: str, documentation_url: str, status_code: int, **kwargs) -> None:
super().__init__(message)
self.documentation_url = documentation_url
self.status = status
self.status_code = status_code
self.kwargs = kwargs
self.message = message
......@@ -164,7 +164,7 @@ class GitHubClient:
headers=self.rest_v3_headers)
data = await resp.json()
if resp.status != 200:
raise GitHubError(status=resp.status, **data)
raise GitHubError(status_code=resp.status, **data)
return Webhook.deserialize(data)
async def create_webhook(self, owner: str, repo: str, url: URL, *, active: bool = True,
......@@ -185,7 +185,7 @@ class GitHubClient:
data=json.dumps(payload), headers=self.rest_v3_headers)
data = await resp.json()
if resp.status != 201:
raise GitHubError(status=resp.status, **data)
raise GitHubError(status_code=resp.status, **data)
return Webhook.deserialize(data)
async def edit_webhook(self, owner: str, repo: str, hook_id: int, *, url: Optional[URL] = None,
......@@ -219,7 +219,7 @@ class GitHubClient:
data=json.dumps(payload), headers=self.rest_v3_headers)
data = await resp.json()
if resp.status != 200:
raise GitHubError(status=resp.status, **data)
raise GitHubError(status_code=resp.status, **data)
return Webhook.deserialize(data)
async def delete_webhook(self, owner: str, repo: str, hook_id: int) -> None:
......@@ -229,4 +229,4 @@ class GitHubClient:
)
if resp.status != 204:
data = await resp.json()
raise GitHubError(status=resp.status, **data)
raise GitHubError(status_code=resp.status, **data)
......@@ -287,7 +287,7 @@ class Commands:
try:
await client.delete_webhook(*repo, hook_id=webhook_info.github_id)
except GitHubError as e:
if e.status == 404:
if e.status_code == 404:
await evt.reply("Webhook deleted successfully")
return
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment