Skip to content

Commit be58b0c

Browse files
author
Andrei Neagu
committed
refactor to use less generic error UnsupportedArchiveFormat
1 parent 7f3e41e commit be58b0c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/service-library/src/servicelib/archiving_utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ class ArchiveError(Exception):
3535
"""
3636

3737

38+
class UnsupportedArchiveFormat(Exception):
39+
pass
40+
41+
3842
def _human_readable_size(size, decimal_places=3):
3943
human_readable_file_size = float(size)
4044
unit = "B"
@@ -260,6 +264,10 @@ async def unarchive_dir(
260264
f"Failed unarchiving {archive_to_extract} -> {destination_folder} due to {type(err)}."
261265
f"Details: {err}"
262266
)
267+
# maybe write unsupported error format here instead of all this to be able to still raise in case of error
268+
if isinstance(err, NotImplementedError):
269+
raise UnsupportedArchiveFormat(msg) from err
270+
263271
raise ArchiveError(msg) from err
264272

265273
# NOTE: extracted_paths includes all tree leafs, which might include files and empty folders

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/nodeports.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
from models_library.services_types import ServicePortKey
2222
from pydantic import ByteSize
2323
from servicelib.archiving_utils import (
24-
ArchiveError,
2524
PrunableFolder,
25+
UnsupportedArchiveFormat,
2626
archive_dir,
2727
unarchive_dir,
2828
)
@@ -307,7 +307,7 @@ async def _get_data_from_port(
307307
dest_folder.prune(exclude=unarchived)
308308

309309
_logger.debug("all unzipped in %s", final_path)
310-
except ArchiveError:
310+
except UnsupportedArchiveFormat:
311311
_logger.warning(
312312
"Could not extract archive '%s' to '%s' moving it to: '%s'",
313313
downloaded_file,

0 commit comments

Comments
 (0)