mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-08-13 08:55:55 -04:00
python work
This commit is contained in:
parent
cd04a8a74c
commit
df0b06bf3c
10 changed files with 1293 additions and 17 deletions
|
@ -1,4 +1,4 @@
|
|||
from typing import Self
|
||||
from typing import Self, Any
|
||||
|
||||
class VeilidAPIError(Exception):
|
||||
"""Veilid API error exception base class"""
|
||||
|
@ -131,3 +131,12 @@ class VeilidAPIErrorGeneric(VeilidAPIError):
|
|||
def __init__(self, message: str):
|
||||
super().__init__("Generic")
|
||||
self.message = message
|
||||
|
||||
|
||||
def raise_api_result(api_result: dict) -> Any:
|
||||
if "value" in api_result:
|
||||
return api_result["value"]
|
||||
elif "error" in api_result:
|
||||
raise VeilidAPIError.from_json(api_result["error"])
|
||||
else:
|
||||
raise ValueError("Invalid format for ApiResult")
|
Loading…
Add table
Add a link
Reference in a new issue