From 9676471d67e6c278ffb61820882182ea85049764 Mon Sep 17 00:00:00 2001 From: mutantsan Date: Tue, 30 Apr 2024 11:34:23 +0300 Subject: [PATCH] fix: show nice error if missing adapter for archive fmt --- ckanext/unfold/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ckanext/unfold/utils.py b/ckanext/unfold/utils.py index 4e234fc..41c769b 100644 --- a/ckanext/unfold/utils.py +++ b/ckanext/unfold/utils.py @@ -9,6 +9,7 @@ import ckan.lib.uploader as uploader from ckan.lib.redis import connect_to_redis +import ckanext.unfold.exception as unf_exception import ckanext.unfold.adapters as unf_adapters import ckanext.unfold.types as unf_types @@ -113,7 +114,7 @@ def get_archive_structure(resource_id: str) -> list[dict[str, Any]] | None: data = conn.get(f"ckanext:unfold:tree:{resource_id}") conn.close() - return json.loads(data) if data else None + return json.loads(data) if data else None # type: ignore def delete_archive_structure(resource_id: str) -> None: @@ -144,7 +145,7 @@ def get_archive_tree( res_format = resource["format"].lower() if res_format not in unf_adapters.ADAPTERS: - raise TypeError(f"No adapter for `{res_format}` archives") + raise unf_exception.UnfoldError(f"No adapter for `{res_format}` archives") tree = unf_adapters.ADAPTERS[res_format](filepath, resource_view, remote=remote)