mc5-api-client 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,78 @@
1
+ # ────────────[ CHIZOBA ]────────────────────────────
2
+ # | Email : chizoba2026@hotmail.com
3
+ # | File : exceptions.py
4
+ # | License : MIT License © 2026 Chizoba
5
+ # | Brief : Custom exceptions for MC5 API Client
6
+ # ────────────────★─────────────────────────────────
7
+
8
+ """
9
+ Custom exceptions for the MC5 API Client.
10
+ """
11
+
12
+
13
+ class MC5APIError(Exception):
14
+ """Base exception for all MC5 API related errors."""
15
+
16
+ def __init__(self, message: str, status_code: int = None, response_data: dict = None):
17
+ super().__init__(message)
18
+ self.message = message
19
+ self.status_code = status_code
20
+ self.response_data = response_data or {}
21
+
22
+ def __str__(self) -> str:
23
+ if self.status_code:
24
+ return f"MC5APIError ({self.status_code}): {self.message}"
25
+ return f"MC5APIError: {self.message}"
26
+
27
+
28
+ class AuthenticationError(MC5APIError):
29
+ """Raised when authentication fails."""
30
+
31
+ def __init__(self, message: str = "Authentication failed"):
32
+ super().__init__(message, status_code=401)
33
+
34
+
35
+ class RateLimitError(MC5APIError):
36
+ """Raised when rate limit is exceeded."""
37
+
38
+ def __init__(self, message: str = "Rate limit exceeded", retry_after: int = None):
39
+ super().__init__(message, status_code=429)
40
+ self.retry_after = retry_after
41
+
42
+
43
+ class InvalidCredentialsError(AuthenticationError):
44
+ """Raised when provided credentials are invalid."""
45
+
46
+ def __init__(self, message: str = "Invalid username or password"):
47
+ super().__init__(message)
48
+
49
+
50
+ class TokenExpiredError(AuthenticationError):
51
+ """Raised when access token has expired."""
52
+
53
+ def __init__(self, message: str = "Access token has expired"):
54
+ super().__init__(message)
55
+
56
+
57
+ class InsufficientScopeError(MC5APIError):
58
+ """Raised when token lacks required scope for an operation."""
59
+
60
+ def __init__(self, required_scope: str):
61
+ message = f"Insufficient scope. Required: {required_scope}"
62
+ super().__init__(message, status_code=403)
63
+ self.required_scope = required_scope
64
+
65
+
66
+ class NetworkError(MC5APIError):
67
+ """Raised when network connectivity issues occur."""
68
+
69
+ def __init__(self, message: str = "Network error occurred"):
70
+ super().__init__(message)
71
+
72
+
73
+ class ValidationError(MC5APIError):
74
+ """Raised when request validation fails."""
75
+
76
+ def __init__(self, message: str = "Validation failed", field: str = None):
77
+ super().__init__(message, status_code=400)
78
+ self.field = field
File without changes
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Chizoba
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.