From 886b7962e4953f2a6a33acd0fdb0245143131dab Mon Sep 17 00:00:00 2001 From: Alex Courouble <56831527+couralex6@users.noreply.github.com> Date: Fri, 24 May 2024 11:07:11 -0700 Subject: [PATCH] raise DuneError if insert failed --- dune_client/api/table.py | 9 +++++---- dune_client/models.py | 8 -------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/dune_client/api/table.py b/dune_client/api/table.py index 90e5e04..28374e8 100644 --- a/dune_client/api/table.py +++ b/dune_client/api/table.py @@ -104,11 +104,12 @@ def insert_table( headers={"Content-Type": content_type}, data=data, ) - if "error" in result_json: - return InsertTableErrorResult.from_dict(result_json) - else: - return InsertTableResult.from_dict(result_json) + # return InsertTableErrorResult.from_dict(result_json) + try: + return InsertTableResult.from_dict(result_json) + except KeyError as err: + raise DuneError(result_json, "ResultsResponse", err) from err def delete_table(self, namespace: str, table_name: str) -> DeleteTableResult: """ diff --git a/dune_client/models.py b/dune_client/models.py index a44fed5..270288f 100644 --- a/dune_client/models.py +++ b/dune_client/models.py @@ -377,14 +377,6 @@ class InsertTableResult(DataClassJsonMixin): rows_written: int bytes_written: int -@dataclass -class InsertTableErrorResult(DataClassJsonMixin): - """ - Data type returned by table/insert operation error - """ - - error: str - @dataclass class DeleteTableResult(DataClassJsonMixin):