-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexception.py
More file actions
105 lines (79 loc) · 3.62 KB
/
exception.py
File metadata and controls
105 lines (79 loc) · 3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
"""Exception definitions"""
class PluginError(Exception):
"""Raised when there is a plugin error."""
def __init__(self, error: str) -> None:
"""Initializes the error.
Args:
error: The error message
"""
self.error = error
super().__init__(error)
class NotSupportedError(Exception):
"""Raised when something is not supported."""
def __init__(self, error: str) -> None:
"""Initializes the error.
Args:
error: The error message
"""
self.error = error
super().__init__(error)
class ProviderInstallationError(Exception):
"""Raised when provider installation fails."""
def __init__(self, provider_name: str, error: str, original_error: Exception | None = None) -> None:
"""Initializes the error.
Args:
provider_name: The name of the provider that failed
error: The error message
original_error: The original exception that caused this error
"""
self.provider_name = provider_name
self.error = error
self.original_error = original_error
super().__init__(f"Provider '{provider_name}' installation failed: {error}")
class ProviderConfigurationError(Exception):
"""Raised when provider configuration is invalid."""
def __init__(self, provider_name: str, error: str, configuration_key: str | None = None) -> None:
"""Initializes the error.
Args:
provider_name: The name of the provider with invalid configuration
error: The error message
configuration_key: The specific configuration key that caused the error
"""
self.provider_name = provider_name
self.error = error
self.configuration_key = configuration_key
message = f"Provider '{provider_name}' configuration error"
if configuration_key:
message += f" in '{configuration_key}'"
message += f': {error}'
super().__init__(message)
class InstallationVerificationError(Exception):
"""Raised when provider artifacts are missing and the user needs to run install first."""
def __init__(self, provider_name: str, missing_artifacts: list[str]) -> None:
"""Initializes the error.
Args:
provider_name: The name of the provider whose artifacts are missing
missing_artifacts: List of descriptions of what is missing
"""
self.provider_name = provider_name
self.missing_artifacts = missing_artifacts
artifact_list = ', '.join(missing_artifacts)
super().__init__(
f"Provider '{provider_name}' artifacts not found: {artifact_list}. "
f"Run 'cppython install' or 'pdm install' before building."
)
class ProviderToolingError(Exception):
"""Raised when provider tooling operations fail."""
def __init__(self, provider_name: str, operation: str, error: str, original_error: Exception | None = None) -> None:
"""Initializes the error.
Args:
provider_name: The name of the provider that failed
operation: The operation that failed (e.g., 'download', 'bootstrap', 'install')
error: The error message
original_error: The original exception that caused this error
"""
self.provider_name = provider_name
self.operation = operation
self.error = error
self.original_error = original_error
super().__init__(f"Provider '{provider_name}' {operation} failed: {error}")