From d1d15296820dc617e4068c9ebe2bbe6e2671b40d Mon Sep 17 00:00:00 2001 From: rhoadesScholar Date: Fri, 6 Dec 2024 09:43:29 -0500 Subject: [PATCH] fix: Improve error handling in ImageWriter for existing files --- src/cellmap_data/image.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cellmap_data/image.py b/src/cellmap_data/image.py index 07bab4b..48a7048 100644 --- a/src/cellmap_data/image.py +++ b/src/cellmap_data/image.py @@ -783,6 +783,10 @@ def array(self) -> xarray.DataArray: try: array = array_future.result() except ValueError as e: + if "ALREADY_EXISTS" in str(e): + raise FileExistsError( + f"Image already exists at {self.path}. Set overwrite=True to overwrite the image." + ) Warning(e) UserWarning("Falling back to zarr3 driver") spec["driver"] = "zarr3"