Skip to content
Snippets Groups Projects
Commit 91c53ba1 authored by Eva Bardou's avatar Eva Bardou Committed by Bastien Abadie
Browse files

Improve API exceptions display when fetching element

parent 3929d33a
No related branches found
No related tags found
1 merge request!3Improve API exceptions display when fetching element
Pipeline #77855 passed
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment