Skip to content

y5gfunc.source.wobbly.core.context

context

Processing contexts and helpers for Wobbly parser.

Functions:

Name Description
safe_processing

Safe processing context manager for catching and transforming exceptions

safe_processing

safe_processing(stage: str, details: Optional[dict[str, Any]] = None) -> Iterator[None]

Safe processing context manager for catching and transforming exceptions

Parameters:

Name Type Description Default

stage

str

Processing stage name

required

details

Optional[dict[str, Any]]

Optional details to include in error

None

Yields:

Type Description
None

Nothing

Source code in y5gfunc/source/wobbly/core/context.py
@contextmanager
def safe_processing(
    stage: str, details: Optional[dict[str, Any]] = None
) -> Iterator[None]:
    """
    Safe processing context manager for catching and transforming exceptions

    Args:
        stage: Processing stage name
        details: Optional details to include in error

    Yields:
        Nothing
    """
    try:
        yield
    except WobblyError:
        # Already a WobblyError, re-raise
        raise
    except Exception as e:
        # Convert other exceptions to WobblyProcessError
        raise WobblyProcessError(
            f"Error during {stage}", stage=stage, details=details, cause=e
        )