Exceptions¶
The exception hierarchy lives in website/exceptions/ and provides structured, domain-specific errors used throughout the service layer.
Hierarchy¶
QuestMasterError # Base for all application errors
+-- NotFoundError # Resource not found
+-- UnauthorizedError # Permission denied
+-- ValidationError # Input validation failure
+-- DatabaseError # Database operation failure
+-- DiscordError # Discord integration base error
| +-- DiscordAPIError # Discord API call failure
+-- GameError # Game-related base error
+-- GameFullError # Game has no open slots
+-- GameClosedError # Game is not accepting registrations
+-- DuplicateRegistrationError # User already registered
+-- SessionConflictError # Session time conflict
Usage¶
Services raise these exceptions. Views catch them and translate to appropriate HTTP responses.
from website.exceptions import GameFullError
def register_player(game_id: int, user: User) -> None:
game = game_repo.get_by_id(game_id)
if game.is_full:
raise GameFullError(f"Game '{game.name}' is full")
# ...
API Reference¶
Custom exception hierarchy for the QuestMaster application.
NotFoundError
¶
Bases: QuestMasterError
Resource not found.
Source code in website/exceptions/base.py
QuestMasterError
¶
Bases: Exception
Base exception for all QuestMaster errors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Human-readable error description. |
required |
code
|
str
|
Machine-readable error code (e.g. "GAME_FULL"). |
None
|
details
|
dict
|
Additional context about the error. |
None
|
Source code in website/exceptions/base.py
UnauthorizedError
¶
Bases: QuestMasterError
User not authorized to perform this action.
Source code in website/exceptions/base.py
DuplicateRegistrationError
¶
Bases: GameError
Player already registered for this game.
Source code in website/exceptions/business.py
GameClosedError
¶
Bases: GameError
Game is closed for registration.
Source code in website/exceptions/business.py
GameError
¶
Bases: QuestMasterError
Game-related business logic error.
Source code in website/exceptions/business.py
GameFullError
¶
Bases: GameError
Game has reached maximum players.
Source code in website/exceptions/business.py
SessionConflictError
¶
Bases: GameError
Game session overlaps with an existing session.
Source code in website/exceptions/business.py
DatabaseError
¶
Bases: QuestMasterError
Database operation failed.
Source code in website/exceptions/database.py
DiscordAPIError
¶
Bases: DiscordError
Discord API request failed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Description of the API error. |
required |
status_code
|
int
|
HTTP status code from the Discord API. |
required |
response
|
dict
|
The raw response body from Discord (optional). |
None
|
Source code in website/exceptions/discord.py
DiscordError
¶
ValidationError
¶
Bases: QuestMasterError
Input validation failed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Description of the validation failure. |
required |
field
|
str
|
The field that failed validation (optional). |
None
|
code
|
str
|
Machine-readable error code. |
None
|
details
|
dict
|
Additional context about the error. |
None
|