Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions src/ere/services/entity_resolution_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
MentionRepository,
SimilarityRepository,
)
from ere.models.exceptions import ConflictError
from ere.models.resolver import (
CandidateCluster,
ClusterId,
Expand Down Expand Up @@ -229,8 +230,6 @@ def check_conflict(self, mention: Mention) -> None:
Raises:
ConflictError: If mention_id already exists with different attributes.
"""
from ere.models.exceptions import ConflictError

existing = self._mention_repo.find_by_id(mention.id)
if existing is not None and existing.attributes != mention.attributes:
raise ConflictError(
Expand Down Expand Up @@ -488,10 +487,11 @@ def process_request(self, request: ERERequest) -> EREResponse:
ere_request_id=request.ere_request_id,
timestamp=now,
)
except Exception as exc: # pylint: disable=broad-exception-caught
log.exception(
"Resolution error for mention %s",
except (ValueError, ConflictError) as exc:
log.error( # NOSONAR - intentionally no traceback for controlled exceptions
"Resolution error for mention %s: %s",
request.ere_request_id,
exc,
)
return EREErrorResponse(
ere_request_id=request.ere_request_id,
Expand All @@ -500,6 +500,18 @@ def process_request(self, request: ERERequest) -> EREResponse:
error_detail=str(exc),
timestamp=now,
)
except Exception: # pylint: disable=broad-exception-caught
log.exception(
"Unexpected error for mention %s",
request.ere_request_id,
)
return EREErrorResponse(
ere_request_id=request.ere_request_id,
error_type="InternalError",
error_title="Unexpected error",
error_detail="An unexpected error occurred",
timestamp=now,
)

def __call__(self, request: ERERequest) -> EREResponse:
"""Make the service callable."""
Expand Down
Loading