Sandbox Command Error (zerobox/errors.py)

zerobox · sdks/python/src/zerobox/errors.py · python · Apache-2.0
dev-tools, security, cli, lang:python, tag:exception, tag:error-handling

Custom exception raised when a sandboxed command execution exits with a non-zero code, capturing exit code, stdout, and stderr for debugging.

# Source: https://github.com/afshinm/zerobox | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
from __future__ import annotations

from .options import CommandOutput


class SandboxCommandError(Exception):
    """Raised when a sandboxed command exits with a non-zero code."""

    def __init__(self, output: CommandOutput) -> None:
        message = (
            output.stderr.strip()
            or output.stdout.strip()
            or f"command exited with code {output.code}"
        )
        super().__init__(message)
        self.code: int = output.code
        self.stdout: str = output.stdout
        self.stderr: str = output.stderr

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key