Skip to content

Commit

Permalink
Raising exception on failed write
Browse files Browse the repository at this point in the history
  • Loading branch information
seboceanum committed Nov 22, 2024
1 parent 479170d commit c55e999
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions oceanum/datamesh/zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,19 @@ def __setitem__(self, item, value):
if self.api == "query":
raise DatameshConnectError("Query api does not support write operations")
if self.method == "put":
requests.put(
res = requests.put(
f"{self._proxy}/{self.datasource}/{item}",
data=value,
headers=self.headers,
)
else:
requests.post(
res = requests.post(
f"{self._proxy}/{self.datasource}/{item}",
data=value,
headers=self.headers,
)
if res.status_code >= 300:
raise DatameshWriteError(f"Failed to write {item}: {res.status_code} - {res.text}")

def __delitem__(self, item):
if self.api == "query":
Expand Down

0 comments on commit c55e999

Please sign in to comment.