Skip to content

Commit

Permalink
feat: Catch ValidationError when reordering resources
Browse files Browse the repository at this point in the history
  • Loading branch information
bellisk committed Dec 2, 2024
1 parent b6f574b commit 6f00e91
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions ckanext/switzerland/harvester/base_sbb_harvester.py
Original file line number Diff line number Diff line change
Expand Up @@ -1104,15 +1104,27 @@ def finalize(self, harvest_object, harvest_object_data):
},
)

# reorder resources
# not matched resources come first in the list, then the ordered
get_action("package_resource_reorder")(
context,
{
"id": package["id"],
"order": [r["id"] for r in unmatched_resources + ordered_resources],
},
)
try:
# reorder resources
# not matched resources come first in the list, then the ordered
get_action("package_resource_reorder")(
context,
{
"id": package["id"],
"order": [r["id"] for r in unmatched_resources + ordered_resources],
},
)
except ValidationError:
self._save_object_error(
f"Error reordering resources for dataset "
f"{harvest_object_data['dataset']}. "
f"This could be due to a failed connection to the database. "
f"{traceback.format_exc()}",
harvest_object,
stage,
)

return False

Session.query(HarvestObject).filter(
HarvestObject.package_id == package["id"]
Expand Down

0 comments on commit 6f00e91

Please sign in to comment.