orchestrata_ultimate.gateway.exceptions

Reference › orchestrata_ultimate › gateway › exceptions

exceptions is the gateway's flat exception hierarchy, rooted at GatewayError. Its subclasses are AuthenticationError (failed credentials), ConnectionLifecycleError, RPCError, RingBufferError, PubSubError and InsecureJWTSecretError (raised by config when the JWT secret is missing or is the development default outside a dev or test context). RPCError carries an rpc_code attribute, which defaults to the JSON-RPC internal-error code, so a handler can raise it with a specific code and the dispatcher in rpc turns it into an error response. Almost every module and handler in the package imports this module. See gateway.

At a glance

Source src/orchestrata_ultimate/gateway/exceptions.py
Lines of code 55
Classes 7
Functions 0
Imports (internal) orchestrata_ultimate.core.base.traces
Imported by orchestrata_ultimate.gateway.auth, orchestrata_ultimate.gateway.auth_handler, orchestrata_ultimate.gateway.config, orchestrata_ultimate.gateway.handlers._policy_gate, orchestrata_ultimate.gateway.handlers._scope_guard, orchestrata_ultimate.gateway.handlers.auth, orchestrata_ultimate.gateway.handlers.cxp, orchestrata_ultimate.gateway.handlers.gateway, orchestrata_ultimate.gateway.handlers.knowledge, orchestrata_ultimate.gateway.handlers.memory, orchestrata_ultimate.gateway.handlers.orchestrator, orchestrata_ultimate.gateway.handlers.state, orchestrata_ultimate.gateway.handlers.ultimatetui, orchestrata_ultimate.gateway.handlers.volk, orchestrata_ultimate.gateway.handlers.workflow, orchestrata_ultimate.gateway.protocol, orchestrata_ultimate.gateway.ring_buffer, orchestrata_ultimate.gateway.rpc, orchestrata_ultimate.gateway.server, scripts.mint_gateway_token
Tests that import it tests/gateway/handlers/test_cxp.py, tests/gateway/handlers/test_knowledge.py, tests/gateway/handlers/test_memory.py, tests/gateway/handlers/test_policy_gate.py, tests/gateway/handlers/test_scope_guard.py, tests/gateway/handlers/test_state.py, tests/gateway/handlers/test_ultimatetui.py, tests/gateway/handlers/test_volk.py, tests/gateway/handlers/test_workflow.py, tests/gateway/test_auth.py, tests/gateway/test_auth_behavioral.py, tests/gateway/test_auth_static_hmac.py, tests/gateway/test_config.py, tests/gateway/test_exceptions.py, tests/gateway/test_exceptions_behavioral.py, tests/gateway/test_gateway_metrics.py, tests/gateway/test_handlers_behavioral.py, tests/gateway/test_orchestrator_intent_parser.py, tests/gateway/test_protocol.py, tests/gateway/test_ring_buffer_behavioral.py, tests/gateway/test_rpc_behavioral.py, tests/gateway/test_spec098_api_standards.py, tests/gateway/test_token_auth.py, tests/generated_gateway/test_exceptions_generated.py, tests/test_gateway.py

Class diagram

Class diagram orchestrata_ultimate.gateway.exceptions

Dependency diagram

Dependency diagram orchestrata_ultimate.gateway.exceptions

API

Classes

GatewayError

Bases: Exception · Line 6

Base exception for all gateway errors.

AuthenticationError

Bases: GatewayError · Line 10

Token authentication failed.

ConnectionLifecycleError

Bases: GatewayError · Line 14

WebSocket connection lifecycle error.

RPCError

Bases: GatewayError · Line 18

RPC method invocation error.

Method Signature Summary
__init__ __init__(message: str, rpc_code: int = -32603) -> None Create an RPC error with an optional JSON-RPC code.

RingBufferError

Bases: GatewayError · Line 41

Redis ring buffer operation error.

PubSubError

Bases: GatewayError · Line 45

Pub/sub operation error.

InsecureJWTSecretError

Bases: GatewayError · Line 49

Raised when JWT_SECRET is missing/default outside dev/test.

Source

Permalink: https://gitlab.com/MSamy/orchestrata-ultimate-architecture/-/blob/a4cbc2bdf/src/orchestrata_ultimate/gateway/exceptions.py

"""Custom exceptions for orchestrata-gateway."""

from orchestrata_ultimate.core.base.traces import traces


class GatewayError(Exception):
    """Base exception for all gateway errors."""


class AuthenticationError(GatewayError):
    """Token authentication failed."""


class ConnectionLifecycleError(GatewayError):
    """WebSocket connection lifecycle error."""


class RPCError(GatewayError):
    """RPC method invocation error.

    Attributes:
        rpc_code: JSON-RPC error code for the response.
    """

    @traces(spec="014", story="US-011", reqs=["REQ-014-180"])
    def __init__(
        self,
        message: str,
        rpc_code: int = -32603,
    ) -> None:
        """Create an RPC error with an optional JSON-RPC code.

        Args:
            message: Human-readable error description.
            rpc_code: JSON-RPC error code (default: internal error).
        """
        super().__init__(message)
        self.rpc_code = rpc_code


class RingBufferError(GatewayError):
    """Redis ring buffer operation error."""


class PubSubError(GatewayError):
    """Pub/sub operation error."""


class InsecureJWTSecretError(GatewayError):
    """Raised when ``JWT_SECRET`` is missing/default outside dev/test.

    SPEC-099 (P0): a deploy that forgets to set ``JWT_SECRET`` must fail
    closed instead of silently accepting the well-known ``"dev-secret"``
    default, which would let anyone forge valid tokens.
    """