diff --git a/arkindex_worker/worker.py b/arkindex_worker/worker.py index 99971d3b464885f738f2d7a2c4a8f80ab3651391..4319bb515a8583c44423da9a37ead0f6d2c11378 100644 --- a/arkindex_worker/worker.py +++ b/arkindex_worker/worker.py @@ -6,6 +6,8 @@ import os import sys import uuid +from apistar.exceptions import ErrorResponse + from arkindex import ArkindexClient, options_from_env from arkindex_worker import logger from arkindex_worker.models import Element @@ -124,12 +126,18 @@ class ElementsWorker(BaseWorker): **self.api_client.request("RetrieveElement", id=element_id) ) logger.info(f"Processing {element} ({i}/{count})") - self.process_element(element) + except ErrorResponse as e: + failed += 1 + logger.warning( + f"An API error occurred while processing element {element_id}: {e.title} - {e.content}", + exc_info=e if self.args.verbose else None, + ) + self.report.error(element_id, e) except Exception as e: failed += 1 logger.warning( - "Failed running worker on {}: {!r}".format(element_id, e), + f"Failed running worker on element {element_id}: {e}", exc_info=e if self.args.verbose else None, ) self.report.error(element_id, e)