|
3 | 3 | """ |
4 | 4 |
|
5 | 5 | from enum import Enum, auto |
6 | | -from typing import Any, Optional, TypedDict |
| 6 | +from typing import Optional, TypedDict |
7 | 7 |
|
8 | 8 | _STANDARD_RATES = ( |
9 | 9 | 8000, |
@@ -130,90 +130,6 @@ def _reason_from_reply(value): |
130 | 130 | return reasonenum |
131 | 131 |
|
132 | 132 |
|
133 | | -class CamillaError(Exception): |
134 | | - """ |
135 | | - Base class for errors returned by CamillaDSP. |
136 | | - The 'message' attribute holds an optional message as a string, |
137 | | - while the 'value' attribute holds an optional value. |
138 | | - """ |
139 | | - |
140 | | - def __init__(self, message: Optional[str] = None, value: Any = None): |
141 | | - self.message = message |
142 | | - self.value = value |
143 | | - super().__init__(self.message) |
144 | | - |
145 | | - |
146 | | -class ShutdownInProgressError(CamillaError): |
147 | | - """ |
148 | | - CamillaDSP is shutting down and unable to handle any more commands. |
149 | | - """ |
150 | | - |
151 | | - |
152 | | -class RateLimitExceededError(CamillaError): |
153 | | - """ |
154 | | - Too many requests were sent. |
155 | | - """ |
156 | | - |
157 | | - |
158 | | -class InvalidValueError(CamillaError): |
159 | | - """ |
160 | | - An invalid value was supplied with a command. |
161 | | - """ |
162 | | - |
163 | | - |
164 | | -class InvalidRequestError(CamillaError): |
165 | | - """ |
166 | | - An invalid command was sent. |
167 | | - """ |
168 | | - |
169 | | - |
170 | | -class InvalidFaderError(CamillaError): |
171 | | - """ |
172 | | - An invalid fader index was supplied with a command. |
173 | | - """ |
174 | | - |
175 | | - |
176 | | -class ConfigValidationError(CamillaError): |
177 | | - """ |
178 | | - The supplied config is invalid. |
179 | | - """ |
180 | | - |
181 | | - |
182 | | -class ConfigReadError(CamillaError): |
183 | | - """ |
184 | | - An error occurred while reading the config file. |
185 | | - """ |
186 | | - |
187 | | - |
188 | | -class UnknownError(CamillaError): |
189 | | - """ |
190 | | - An unknown error occurred. |
191 | | - This should only happen if this library is used |
192 | | - with a different version of CamillaDSP than it was intended for. |
193 | | - """ |
194 | | - |
195 | | - |
196 | | -def raise_error(state: str, message: Optional[str], value: Any): |
197 | | - """ |
198 | | - Raise the appropriate exception for the given error state. |
199 | | - """ |
200 | | - if state == "RateLimitExceededError": |
201 | | - raise RateLimitExceededError() |
202 | | - if state == "ShutdownInProgressError": |
203 | | - raise ShutdownInProgressError() |
204 | | - if state == "InvalidValueError": |
205 | | - raise InvalidValueError(message=message, value=value) |
206 | | - if state == "InvalidRequestError": |
207 | | - raise InvalidRequestError(message=message, value=value) |
208 | | - if state == "InvalidFaderError": |
209 | | - raise InvalidFaderError(value=value) |
210 | | - if state == "ConfigValidationError": |
211 | | - raise ConfigValidationError(message=message, value=value) |
212 | | - if state == "ConfigReadError": |
213 | | - raise ConfigReadError(message=message, value=value) |
214 | | - raise UnknownError(message=message, value=value) |
215 | | - |
216 | | - |
217 | 133 | class Fader(TypedDict): |
218 | 134 | """ |
219 | 135 | Class for type annotation of fader volume and mute settings. |
|
0 commit comments