Skip to content

Commit

Permalink
chore: refactor get_error_type
Browse files Browse the repository at this point in the history
Signed-off-by: Guilhem Barthés <[email protected]>
  • Loading branch information
guilhem-barthes committed Aug 13, 2024
1 parent 567314e commit 2622aeb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions backend/substrapp/tasks/tasks_asset_failure_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from django.conf import settings

from backend.celery import app
from builder import exceptions as builder_errors
from orchestrator import failure_report_pb2
from orchestrator import get_orchestrator_client
from substrapp.compute_tasks import errors as compute_task_errors
Expand Down Expand Up @@ -76,9 +75,12 @@ def get_error_type(exc: Exception) -> failure_report_pb2.ErrorType.ValueType:
The error type corresponding to the exception.
"""

if isinstance(exc, (compute_task_errors._ComputeTaskError, builder_errors._BuildError)):
if not hasattr(exc, "logs"):
return compute_task_errors.ComputeTaskErrorType.INTERNAL_ERROR.value

try:
error_type = exc.error_type
else:
except AttributeError:
error_type = compute_task_errors.ComputeTaskErrorType.INTERNAL_ERROR

return error_type.value

0 comments on commit 2622aeb

Please sign in to comment.