Skip to content

Commit 3a4d78f

Browse files
fix: add custom error
1 parent c55fb07 commit 3a4d78f

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

packages/celery-library/src/celery_library/errors.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,11 @@ def decode_celery_transferrable_error(error: TransferrableCeleryError) -> Except
2626
return result
2727

2828

29+
class TaskSubmissionError(OsparcErrorMixin, Exception):
30+
msg_template = (
31+
"Unable to submit task {task_name} with id '{task_id}' and params {task_params}"
32+
)
33+
34+
2935
class TaskNotFoundError(OsparcErrorMixin, Exception):
3036
msg_template = "Task with id '{task_id}' was not found"

packages/celery-library/src/celery_library/task_manager.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from servicelib.logging_utils import log_context
2424
from settings_library.celery import CelerySettings
2525

26-
from .errors import TaskNotFoundError
26+
from .errors import TaskNotFoundError, TaskSubmissionError
2727

2828
_logger = logging.getLogger(__name__)
2929

@@ -87,7 +87,11 @@ async def submit_task(
8787
"Unable to cleanup task '%s' during error handling",
8888
task_id,
8989
)
90-
raise
90+
raise TaskSubmissionError(
91+
task_name=task_metadata.name,
92+
task_id=task_id,
93+
task_params=task_params,
94+
) from exc
9195

9296
return task_uuid
9397

0 commit comments

Comments
 (0)