File tree Expand file tree Collapse file tree 4 files changed +31
-30
lines changed
Expand file tree Collapse file tree 4 files changed +31
-30
lines changed Original file line number Diff line number Diff line change 2020
2121from ghutils .common .__version__ import VERSION
2222from ghutils .core .cog import GHUtilsCog , SubGroup
23- from ghutils .core .types import InvalidInputError , LoginState , NotLoggedInError
23+ from ghutils .core .exceptions import InvalidInputError , NotLoggedInError
24+ from ghutils .core .types import LoginState
2425from ghutils .db .models import (
2526 UserGitHubTokens ,
2627 UserLogin ,
Original file line number Diff line number Diff line change 1+ from typing import Any
2+
3+ from discord .app_commands import AppCommandError
4+
5+
6+ # TODO: add Literal[LoginState.LOGGED_OUT, LoginState.EXPIRED] parameter
7+ class NotLoggedInError (AppCommandError ):
8+ """An exception raised when the command user is not logged in to GitHub.
9+
10+ Commands that require the user of the command to log in with GitHub can throw this
11+ if the user is not logged in to reply with a standard error message.
12+ """
13+
14+
15+ class SilentError (AppCommandError ):
16+ """Base class for exceptions that should be silently caught and ignored."""
17+
18+
19+ class InvalidInputError (AppCommandError ):
20+ """An exception raised within command handlers when an input value is invalid.
21+
22+ Displays a similar error message as `TransformerError`.
23+ """
24+
25+ def __init__ (self , value : Any , message : str ):
26+ self .value = value
27+ self .message = message
28+ super ().__init__ (f"{ message } (value: { value } )" )
Original file line number Diff line number Diff line change 1010 TransformerError ,
1111)
1212
13- from .types import InvalidInputError , NotLoggedInError , SilentError
13+ from .exceptions import InvalidInputError , NotLoggedInError , SilentError
1414
1515
1616class GHUtilsCommandTree (CommandTree ):
Original file line number Diff line number Diff line change 11from enum import Enum , auto
2- from typing import Any
3-
4- from discord .app_commands import AppCommandError
52
63
74class LoginState (Enum ):
85 LOGGED_IN = auto ()
96 LOGGED_OUT = auto ()
107 EXPIRED = auto ()
11-
12-
13- # TODO: add Literal[LoginState.LOGGED_OUT, LoginState.EXPIRED] parameter
14- class NotLoggedInError (AppCommandError ):
15- """An exception raised when the command user is not logged in to GitHub.
16-
17- Commands that require the user of the command to log in with GitHub can throw this
18- if the user is not logged in to reply with a standard error message.
19- """
20-
21-
22- class SilentError (AppCommandError ):
23- """Base class for exceptions that should be silently caught and ignored."""
24-
25-
26- class InvalidInputError (AppCommandError ):
27- """An exception raised within command handlers when an input value is invalid.
28-
29- Displays a similar error message as `TransformerError`.
30- """
31-
32- def __init__ (self , value : Any , message : str ):
33- self .value = value
34- self .message = message
35- super ().__init__ (f"{ message } (value: { value } )" )
You can’t perform that action at this time.
0 commit comments