julee.domain.use_cases.decorators

Decorators for use case step error handling and logging.

This module provides decorators that implement consistent error handling and logging patterns across all use cases in the julee domain, following the patterns established in the sample use cases.

Attributes

Functions

try_use_case_step(step_name[, extra_context])

Decorator that wraps use case steps with consistent error handling and

Module Contents

julee.domain.use_cases.decorators.try_use_case_step(step_name, extra_context=None)[source]

Decorator that wraps use case steps with consistent error handling and logging.

This decorator provides the same error handling and logging pattern used in the sample use cases, eliminating boilerplate and ensuring consistency across all use case implementations.

Parameters:
  • step_name (str) – Name of the step (e.g., “assembly_id_generation”)

  • extra_context (dict[str, Any] | None) – Optional additional context to include in all log messages

Returns:

Decorated function with consistent error handling and logging

Return type:

collections.abc.Callable[[F], F]

Example

>>> @try_use_case_step(
...     "assembly_id_generation", {"document_id": "doc-123"}
... )
>>> async def generate_assembly_id(self) -> str:
...     return await self.assembly_repo.generate_id()
julee.domain.use_cases.decorators.F[source]
julee.domain.use_cases.decorators.logger[source]