Skip to content

Commit 736a235

Browse files
committed
Add SilentError type
1 parent fe952b3 commit 736a235

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

bot/src/ghutils/core/tree.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010
TransformerError,
1111
)
1212

13-
from ghutils.core.types import NotLoggedInError
13+
from .types import NotLoggedInError, SilentError
1414

1515

1616
class GHUtilsCommandTree(CommandTree):
1717
async def on_error(self, interaction: Interaction, error: AppCommandError):
18+
if isinstance(error, SilentError):
19+
return
20+
1821
if interaction.response.is_done():
1922
await super().on_error(interaction, error)
2023
return

bot/src/ghutils/core/types.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,14 @@ class LoginState(Enum):
99
EXPIRED = auto()
1010

1111

12+
# TODO: add Literal[LoginState.LOGGED_OUT, LoginState.EXPIRED] parameter
1213
class NotLoggedInError(AppCommandError):
13-
pass
14+
"""An exception raised when the command user is not logged in to GitHub.
15+
16+
Commands that require the user of the command to log in with GitHub can throw this
17+
if the user is not logged in to reply with a standard error message.
18+
"""
19+
20+
21+
class SilentError(AppCommandError):
22+
"""Base class for exceptions that should be silently caught and ignored."""

0 commit comments

Comments
 (0)