20
20
from pydantic import BaseModel
21
21
from taskiq import AsyncTaskiqDecoratedTask , TaskiqEvents
22
22
23
- from .exceptions import ContainerTypeMismatchError , InvalidContainerTypeError , NoSignerLoaded
23
+ from .exceptions import (
24
+ ContainerTypeMismatchError ,
25
+ InvalidContainerConfigurationError ,
26
+ InvalidContainerTypeError ,
27
+ NoSignerLoaded ,
28
+ )
24
29
from .settings import Settings
25
30
from .state import StateSnapshot
26
31
from .types import ScalarType , SilverbackID , TaskType
@@ -402,6 +407,8 @@ def broker_task_decorator(
402
407
:class:`~silverback.exceptions.ContainerTypeMismatchError`:
403
408
If there is a mismatch between `task_type` and the `container`
404
409
type it should handle.
410
+ :class:`~silverback.exceptions.ContainerConfigurationError`:
411
+ If there is an issue with the arguments provided.
405
412
"""
406
413
if (
407
414
(task_type is TaskType .NEW_BLOCK and not isinstance (container , BlockContainer ))
@@ -422,9 +429,10 @@ def broker_task_decorator(
422
429
423
430
elif isinstance (container , ContractEventWrapper ):
424
431
if len (container .events ) != 1 :
425
- raise InvalidContainerTypeError (
432
+ raise InvalidContainerConfigurationError (
426
433
f"Requires exactly 1 event to unwrap: { container .events } "
427
434
)
435
+
428
436
container = container .events [0 ]
429
437
430
438
# Register user function as task handler with our broker
@@ -466,7 +474,7 @@ def add_taskiq_task(
466
474
# NOTE: Will clean up extra Nones in `encode_topics_to_string`
467
475
468
476
if unmatched_args := "', '" .join (filter_args ):
469
- raise InvalidContainerTypeError (
477
+ raise InvalidContainerConfigurationError (
470
478
f"Args are not available for filtering: '{ unmatched_args } '."
471
479
)
472
480
@@ -479,7 +487,7 @@ def add_taskiq_task(
479
487
if not cron_schedule or not pycron .has_been (
480
488
cron_schedule , datetime .now () - timedelta (days = 366 )
481
489
):
482
- raise InvalidContainerTypeError (
490
+ raise InvalidContainerConfigurationError (
483
491
f"'{ cron_schedule } ' is not a valid cron schedule"
484
492
)
485
493
0 commit comments