Skip to content

Commit 918ad9f

Browse files
authored
🐛 fix graphql error catch
1 parent f0f7f3a commit 918ad9f

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

nonebot/adapters/github/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from .bot import GitHubBot as GitHubBot
66
from .message import Message as Message
77
from .exception import ActionFailed as ActionFailed
8+
from .exception import GraphQLError as GraphQLError
89
from .exception import NetworkError as NetworkError
910
from .exception import ActionTimeout as ActionTimeout
1011
from .message import MessageSegment as MessageSegment

nonebot/adapters/github/adapter.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from nonebot.typing import overrides
88
from githubkit.webhooks import verify
9-
from githubkit.exception import RequestFailed, RequestTimeout
9+
from githubkit.exception import GraphQLFailed, RequestFailed, RequestTimeout
1010
from nonebot.drivers import (
1111
URL,
1212
Driver,
@@ -23,7 +23,7 @@
2323
from .bot import Bot, OAuthBot, GitHubBot
2424
from .message import Message, MessageSegment
2525
from .config import Config, OAuthApp, GitHubApp
26-
from .exception import ActionFailed, NetworkError, ActionTimeout
26+
from .exception import ActionFailed, GraphQLError, NetworkError, ActionTimeout
2727

2828

2929
class Adapter(BaseAdapter):
@@ -111,6 +111,8 @@ async def _call_api(self, bot: Bot, api: str, **data: Any) -> Any:
111111
raise ActionFailed(e.response) from None
112112
except RequestTimeout as e:
113113
raise ActionTimeout(e.request) from None
114+
except GraphQLFailed as e:
115+
raise GraphQLError(e.response) from None
114116
except Exception as e:
115117
raise NetworkError(f"API request failed: {e!r}") from e
116118

nonebot/adapters/github/exception.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
from typing import Optional
99

1010
from nonebot.exception import AdapterException
11-
from githubkit.exception import RequestFailed, RequestTimeout
1211
from nonebot.exception import ActionFailed as BaseActionFailed
1312
from nonebot.exception import NetworkError as BaseNetworkError
13+
from githubkit.exception import GraphQLFailed, RequestFailed, RequestTimeout
1414

1515

1616
class GitHubAdapterException(AdapterException):
@@ -34,3 +34,7 @@ class ActionTimeout(RequestTimeout, NetworkError):
3434

3535
class ActionFailed(RequestFailed, BaseActionFailed, GitHubAdapterException):
3636
...
37+
38+
39+
class GraphQLError(GraphQLFailed, BaseActionFailed, GitHubAdapterException):
40+
...

0 commit comments

Comments
 (0)