Skip to content

Commit

Permalink
fix: show nice error if missing adapter for archive fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
mutantsan committed Apr 30, 2024
1 parent 148e11c commit 9676471
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ckanext/unfold/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 9676471

Please sign in to comment.