Skip to content

Commit d35093a

Browse files
committed
Finish port
1 parent 2a034a6 commit d35093a

File tree

8 files changed

+55
-7
lines changed

8 files changed

+55
-7
lines changed

packages/caido-sdk-client/src/caido_sdk_client/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
BaseError,
1818
InstanceNotReadyError,
1919
NoViewerInResponseError,
20+
RankUserError,
2021
UnsupportedViewerTypeError,
2122
from_error,
2223
)
@@ -194,6 +195,7 @@
194195
"PATAuthOptions",
195196
"ProjectSDK",
196197
"RangeInput",
198+
"RankUserError",
197199
"ReadyOptions",
198200
"ReplayCollectionSDK",
199201
"ReplayCollectionsListBuilder",

packages/caido-sdk-client/src/caido_sdk_client/errors/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from caido_sdk_client.errors.misc import (
2424
NotFoundUserError,
2525
OtherUserError,
26+
RankUserError,
2627
ReadOnlyUserError,
2728
)
2829
from caido_sdk_client.errors.plugin import (
@@ -58,6 +59,7 @@
5859
"PluginFunctionCallError",
5960
"PluginUserError",
6061
"ProjectUserError",
62+
"RankUserError",
6163
"ReadOnlyUserError",
6264
"RestRequestError",
6365
"StoreUserError",

packages/caido-sdk-client/src/caido_sdk_client/errors/all_errors.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
PermissionDeniedUserErrorFull,
1515
PluginUserErrorFull,
1616
ProjectUserErrorFull,
17+
RankUserErrorFull,
1718
ReadOnlyUserErrorFull,
1819
StoreUserErrorFull,
1920
TaskInProgressUserErrorFull,
@@ -34,6 +35,7 @@
3435
CloudUserErrorFull,
3536
PluginUserErrorFull,
3637
StoreUserErrorFull,
38+
RankUserErrorFull,
3739
TaskInProgressUserErrorFull,
3840
WorkflowUserErrorFull,
3941
]

packages/caido-sdk-client/src/caido_sdk_client/errors/from_error.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313
from caido_sdk_client.errors.misc import (
1414
NotFoundUserError,
1515
OtherUserError,
16+
RankUserError,
1617
ReadOnlyUserError,
1718
)
1819
from caido_sdk_client.errors.plugin import PluginUserError, StoreUserError
1920
from caido_sdk_client.errors.project import ProjectUserError
2021
from caido_sdk_client.errors.tasks import TaskInProgressUserError
2122
from caido_sdk_client.errors.version import NewerVersionUserError
2223
from caido_sdk_client.errors.workflow import WorkflowUserError
24+
from caido_sdk_client.graphql.__generated__.schema import RankErrorReason
2325

2426

2527
def from_error(error: object) -> BaseError:
@@ -65,6 +67,19 @@ def from_error(error: object) -> BaseError:
6567
case "StoreUserError":
6668
return StoreUserError(error) # type: ignore[arg-type]
6769

70+
case "RankUserError":
71+
code = getattr(error, "code", "")
72+
rank_reason_val = getattr(
73+
error, "rankReason", getattr(error, "rank_reason", None)
74+
)
75+
if isinstance(rank_reason_val, RankErrorReason):
76+
rank_reason = rank_reason_val
77+
elif rank_reason_val is not None:
78+
rank_reason = RankErrorReason(str(rank_reason_val))
79+
else:
80+
rank_reason = RankErrorReason.NOT_ENABLED # fallback
81+
return RankUserError(code, rank_reason)
82+
6883
case "TaskInProgressUserError":
6984
return TaskInProgressUserError(getattr(error, "taskId", ""))
7085

packages/caido-sdk-client/src/caido_sdk_client/errors/misc.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
from caido_sdk_client.errors.base import BaseError
6+
from caido_sdk_client.graphql.__generated__.schema import RankErrorReason
67

78

89
class NotFoundUserError(BaseError):
@@ -21,3 +22,8 @@ def __init__(self, code: str, message: str | None = None) -> None:
2122
super().__init__(message)
2223
else:
2324
super().__init__(f"An unknown user error occured: {code!r}")
25+
26+
27+
class RankUserError(BaseError):
28+
def __init__(self, code: str, rank_reason: RankErrorReason) -> None:
29+
super().__init__(f"Ranking failed: {code}: {rank_reason!s}")

packages/caido-sdk-client/src/caido_sdk_client/graphql/__generated__/schema.py

Lines changed: 20 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/caido-sdk-client/src/caido_sdk_client/graphql/documents/errors.graphql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ fragment StoreUserErrorFull on StoreUserError {
6161
storeReason: reason
6262
}
6363

64-
# fragment RankUserErrorFull on RankUserError {
65-
# ...UserErrorFull
66-
# rankReason: reason
67-
# }
64+
fragment RankUserErrorFull on RankUserError {
65+
...UserErrorFull
66+
rankReason: reason
67+
}
6868

6969
fragment TaskInProgressUserErrorFull on TaskInProgressUserError {
7070
...UserErrorFull

packages/caido-sdk-client/src/caido_sdk_client/graphql/documents/task.graphql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ subscription FinishedTask {
4444
}
4545
status
4646
error {
47+
__typename
4748
code
49+
... on RankUserError {
50+
...RankUserErrorFull
51+
}
4852
}
4953
}
5054
}

0 commit comments

Comments
 (0)