Authsome Error Hierarchy (authsome/errors.py)

authsome · src/authsome/errors.py · python · MIT
auth, security, lang:python, tag:exceptions

Defines a standardized set of typed exceptions for authentication and authorization providers. Use this to handle and categorize auth-related failures consistently.

# Source: https://github.com/agentrhq/authsome | License: MIT | Copyright 2024 Manoj Bajaj
# Provided via justclaw.it.com; keep this notice with the code.
"""Error hierarchy for authsome.

Spec §19.2: Expected error categories mapped to typed exceptions.
"""


class AuthsomeError(Exception):
    """Base exception for all authsome errors."""

    def __init__(self, message: str, *, provider: str | None = None, operation: str | None = None) -> None:
        self.provider = provider
        self.operation = operation
        parts: list[str] = []
        if provider:
            parts.append(f"[{provider}]")
        if operation:
            parts.append(f"({operation})")
        parts.append(message)
        super().__init__(" ".join(parts))

    def __str__(self) -> str:
        return f"{s

... (truncated -- full source via MCP)

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

Get a free API key