Skip to content

Commit 7396e69

Browse files
committed
Azure: Add new models and exceptions
This commit introduces a new model named `ConfigureError` and exceptions named `ConflictError` and `RunningSubmissionError` which aims to provide a more detailed status of an Azure Publishing Error. The goal is to be able to differentiate certain errors which are caused by submission in progress/conflict. Assisted-By: Cursor Signed-off-by: Jonathan Gangi <[email protected]>
1 parent 1401cd5 commit 7396e69

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

cloudpub/error.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ class InvalidStateError(RuntimeError):
1717
"""Report invalid state which should not happen in code."""
1818

1919

20+
class ConflictError(Exception):
21+
"""Report a submission conflict error."""
22+
23+
24+
class RunningSubmissionError(Exception):
25+
"""Report a running submission error."""
26+
27+
2028
class NotFoundError(ValueError):
2129
"""Represent a missing resource."""
2230

cloudpub/models/ms_azure.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@ def _mask_secret(value: str) -> str:
2828
return value
2929

3030

31+
@define
32+
class ConfigureError(AttrsJSONDecodeMixin):
33+
"""Represent an error from a :meth:`~AzureService.configure` request."""
34+
35+
code: str
36+
"""The error code."""
37+
38+
message: str
39+
"""The error message."""
40+
41+
resource_id: str = field(metadata={"alias": "resourceId"})
42+
"""The resource ID."""
43+
44+
3145
@define
3246
class ConfigureStatus(AttrsJSONDecodeMixin):
3347
"""Represent a response from a :meth:`~AzureService.configure` request."""
@@ -67,7 +81,10 @@ class ConfigureStatus(AttrsJSONDecodeMixin):
6781
resource_uri: Optional[str] = field(metadata={"alias": "resourceUri", "hide_unset": True})
6882
"""The resource URI related to the configure job."""
6983

70-
errors: List[str]
84+
errors: List[ConfigureError] = field(
85+
converter=lambda x: [ConfigureError.from_json(r) for r in x] if x else [],
86+
on_setattr=NO_OP,
87+
)
7188
"""List of errors when the ``job_result`` is ``failed``."""
7289

7390

0 commit comments

Comments
 (0)