/
/
/
1"""Errors for the Music Quiz provider."""
2
3from __future__ import annotations
4
5from music_assistant_models.errors import InvalidDataError, MusicAssistantError
6
7# all Music Quiz error messages resolve against the provider's own strings.json
8TRANSLATION_OWNER = "provider.music_quiz"
9
10
11class MusicQuizNoGameError(MusicAssistantError):
12 """Raised when there is no active Music Quiz game."""
13
14 # provider-specific code, far above the core error codes in music_assistant_models
15 error_code = 1001
16 translation_key = "music_quiz_no_game"
17 translation_owner = TRANSLATION_OWNER
18
19
20class MusicQuizGameActiveError(InvalidDataError):
21 """Raised when an action requires the current game to be finished first."""
22
23 error_code = 1002
24 translation_key = "music_quiz_game_active"
25 translation_owner = TRANSLATION_OWNER
26
27
28# the webserver localizes error details from the (generic) translation_key of
29# the error type, losing the specific message text: guest-facing errors need
30# their own stable codes so the frontend can present actionable messages
31
32
33class MusicQuizNameTakenError(InvalidDataError):
34 """Raised when a player name is already used in the game."""
35
36 error_code = 1003
37 translation_key = "music_quiz_name_taken"
38 translation_owner = TRANSLATION_OWNER
39
40
41class MusicQuizGameFullError(InvalidDataError):
42 """Raised when a game reached its player limit."""
43
44 error_code = 1004
45 translation_key = "music_quiz_game_full"
46 translation_owner = TRANSLATION_OWNER
47
48
49class MusicQuizAlreadyAnsweredError(InvalidDataError):
50 """Raised when a player answers a round twice."""
51
52 error_code = 1005
53 translation_key = "music_quiz_already_answered"
54 translation_owner = TRANSLATION_OWNER
55
56
57class MusicQuizNotActiveThisRoundError(InvalidDataError):
58 """Raised when a late joiner answers the round that was already playing."""
59
60 error_code = 1006
61 translation_key = "music_quiz_not_active_this_round"
62 translation_owner = TRANSLATION_OWNER
63
64
65class MusicQuizWrongPhaseError(InvalidDataError):
66 """Raised when an action does not match the game's current phase."""
67
68 error_code = 1007
69 translation_key = "music_quiz_wrong_phase"
70 translation_owner = TRANSLATION_OWNER
71
72
73class MusicQuizNoPlaybackTargetError(InvalidDataError):
74 """Raised when a round cannot start because no playback target is available."""
75
76 error_code = 1008
77 translation_key = "music_quiz_no_playback_target"
78 translation_owner = TRANSLATION_OWNER
79
80
81class MusicQuizUnknownPlayerError(InvalidDataError):
82 """Raised when a guest refers to a player that is not in the game."""
83
84 error_code = 1009
85 translation_key = "music_quiz_unknown_player"
86 translation_owner = TRANSLATION_OWNER
87
88
89class MusicQuizUnknownSuggestionError(InvalidDataError):
90 """Raised when a guest answers with a suggestion that is not part of the round."""
91
92 error_code = 1010
93 translation_key = "music_quiz_unknown_suggestion"
94 translation_owner = TRANSLATION_OWNER
95
96
97class MusicQuizInvalidAnswerError(InvalidDataError):
98 """Raised when an answer submission is malformed or mismatched."""
99
100 error_code = 1011
101 translation_key = "music_quiz_invalid_answer"
102 translation_owner = TRANSLATION_OWNER
103