Skip to content

Commit

Permalink
Use logging.exception to fix G200
Browse files Browse the repository at this point in the history
  • Loading branch information
sbesson committed Aug 9, 2022
1 parent 664cbfd commit 4feb066
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
8 changes: 4 additions & 4 deletions ome_zarr/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ def get_json(self, subpath: str) -> JSONDict:
except KeyError:
LOGGER.debug("JSON not found: %s", subpath)
return {}
except Exception as e:
LOGGER.exception("%s", e)
except Exception:
LOGGER.exception("Error while loading JSON")
return {}

def parts(self) -> List[str]:
Expand Down Expand Up @@ -190,7 +190,7 @@ def parse_url(
return None
else:
return loc
except Exception as e:
LOGGER.warning("exception on parsing: %s (stacktrace at DEBUG)", e)
except Exception:
LOGGER.exception("exception on parsing (stacktrace at DEBUG)")
LOGGER.debug("stacktrace:", exc_info=True)
return None
17 changes: 8 additions & 9 deletions ome_zarr/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ def __init__(self, node: Node) -> None:
else:
raise Exception("not bool or int")

except Exception as e:
LOGGER.error("invalid color - %s: %s", color, e)
except Exception:
LOGGER.exception("invalid color - %s", color)

properties: Dict[int, Dict[str, str]] = {}
props_list = image_label.get("properties", [])
Expand Down Expand Up @@ -296,8 +296,8 @@ def __init__(self, node: Node) -> None:
if any(trans is not None for trans in transformations):
node.metadata["coordinateTransformations"] = transformations
LOGGER.info("datasets %s", datasets)
except Exception as e:
LOGGER.error("failed to parse multiscale metadata: %s", e)
except Exception:
LOGGER.exception("Failed to parse multiscale metadata")
return # EARLY EXIT

for resolution in self.datasets:
Expand Down Expand Up @@ -392,8 +392,8 @@ def __init__(self, node: Node) -> None:
node.metadata["contrast_limits"] = contrast_limits
node.metadata["colormap"] = colormaps

except Exception as e:
LOGGER.error("failed to parse metadata: %s", e)
except Exception:
LOGGER.exception("Failed to parse metadata")


class Well(Spec):
Expand Down Expand Up @@ -546,9 +546,8 @@ def get_tile(tile_name: str) -> np.ndarray:

try:
data = self.zarr.load(path)
except ValueError as e:
LOGGER.error("Failed to load %s", path)
LOGGER.debug("%s", e)
except ValueError:
LOGGER.exception("Failed to load %s", path)
data = np.zeros(tile_shape, dtype=self.numpy_type)
return data

Expand Down

0 comments on commit 4feb066

Please sign in to comment.