API: async signal integration migration

This commit is contained in:
Johannes Kirschbauer
2024-07-16 11:28:20 +02:00
parent ce387482bb
commit cc238ecc60
4 changed files with 15 additions and 12 deletions

View File

@@ -22,14 +22,12 @@ class ApiError:
class SuccessDataClass(Generic[ResponseDataType]):
status: Annotated[Literal["success"], "The status of the response."]
data: ResponseDataType
op_key: str | None
@dataclass
class ErrorDataClass:
status: Literal["error"]
errors: list[ApiError]
op_key: str | None
ApiResponse = SuccessDataClass[ResponseDataType] | ErrorDataClass
@@ -109,11 +107,10 @@ API.register(open_file)
) -> ApiResponse[T]:
try:
data: T = fn(*args, **kwargs)
return SuccessDataClass(status="success", data=data, op_key=op_key)
return SuccessDataClass(status="success", data=data)
except ClanError as e:
return ErrorDataClass(
status="error",
op_key=op_key,
errors=[
ApiError(
message=e.msg,