Edit on GitHub

agent_search_gateway.errors

Stable gateway error taxonomy and user-facing constants.

 1"""Stable gateway error taxonomy and user-facing constants."""
 2
 3from enum import StrEnum
 4
 5
 6class ErrorCode(StrEnum):
 7    BAD_REQUEST = "bad_request"
 8    EMPTY_QUERY = "empty_query"
 9    INVALID_URL = "invalid_url"
10    URL_NOT_ADMITTED = "url_not_admitted"
11    NO_KEYWORD_SEARCH_PROVIDERS = "no_keyword_search_providers"
12    NO_LLM_SEARCH_PROVIDERS = "no_llm_search_providers"
13    NO_URL_FETCH_PROVIDERS = "no_url_fetch_providers"
14    NO_ACADEMIC_SEARCH_PROVIDERS = "no_academic_search_providers"
15    ALL_PROVIDERS_FAILED = "all_providers_failed"
16    LLM_STAGE_FAILED = "llm_stage_failed"
17    PROTOCOL_ERROR = "protocol_error"
18    CONFIG_ERROR = "config_error"
19    DAEMON_SHUTTING_DOWN = "daemon_shutting_down"
20
21
22UNAVAILABLE_MESSAGE = (
23    "URL unavailable: it may have failed content validation or been flagged as unsafe."
24)
25
26
27class GatewayError(Exception):
28    """Base typed failure crossing orchestration boundaries."""
29
30    def __init__(
31        self,
32        code: ErrorCode,
33        message: str,
34        *,
35        reason: str | None = None,
36    ) -> None:
37        super().__init__(message)
38        self.code = code
39        self.message = message
40        self.reason = reason
41
42
43class InputFailure(GatewayError):
44    """Invalid user input or request-state combination."""
45
46
47class ExecutionFailure(GatewayError):
48    """Dependency or execution-path failure."""
49
50
51class ProtocolFailure(ExecutionFailure):
52    """Malformed local or provider protocol data."""
53
54
55class ConfigFailure(GatewayError):
56    """Invalid daemon startup configuration."""
57
58
59class ParserFailure(ExecutionFailure):
60    """Restricted parser rejected an execution result."""
61
62    def __init__(self, message: str) -> None:
63        super().__init__(ErrorCode.PROTOCOL_ERROR, message)
64
65
66class DaemonUnavailable(Exception):
67    """The local daemon socket is missing or refusing connections."""
class ErrorCode(enum.StrEnum):
 7class ErrorCode(StrEnum):
 8    BAD_REQUEST = "bad_request"
 9    EMPTY_QUERY = "empty_query"
10    INVALID_URL = "invalid_url"
11    URL_NOT_ADMITTED = "url_not_admitted"
12    NO_KEYWORD_SEARCH_PROVIDERS = "no_keyword_search_providers"
13    NO_LLM_SEARCH_PROVIDERS = "no_llm_search_providers"
14    NO_URL_FETCH_PROVIDERS = "no_url_fetch_providers"
15    NO_ACADEMIC_SEARCH_PROVIDERS = "no_academic_search_providers"
16    ALL_PROVIDERS_FAILED = "all_providers_failed"
17    LLM_STAGE_FAILED = "llm_stage_failed"
18    PROTOCOL_ERROR = "protocol_error"
19    CONFIG_ERROR = "config_error"
20    DAEMON_SHUTTING_DOWN = "daemon_shutting_down"
BAD_REQUEST = <ErrorCode.BAD_REQUEST: 'bad_request'>
EMPTY_QUERY = <ErrorCode.EMPTY_QUERY: 'empty_query'>
INVALID_URL = <ErrorCode.INVALID_URL: 'invalid_url'>
URL_NOT_ADMITTED = <ErrorCode.URL_NOT_ADMITTED: 'url_not_admitted'>
NO_KEYWORD_SEARCH_PROVIDERS = <ErrorCode.NO_KEYWORD_SEARCH_PROVIDERS: 'no_keyword_search_providers'>
NO_LLM_SEARCH_PROVIDERS = <ErrorCode.NO_LLM_SEARCH_PROVIDERS: 'no_llm_search_providers'>
NO_URL_FETCH_PROVIDERS = <ErrorCode.NO_URL_FETCH_PROVIDERS: 'no_url_fetch_providers'>
NO_ACADEMIC_SEARCH_PROVIDERS = <ErrorCode.NO_ACADEMIC_SEARCH_PROVIDERS: 'no_academic_search_providers'>
ALL_PROVIDERS_FAILED = <ErrorCode.ALL_PROVIDERS_FAILED: 'all_providers_failed'>
LLM_STAGE_FAILED = <ErrorCode.LLM_STAGE_FAILED: 'llm_stage_failed'>
PROTOCOL_ERROR = <ErrorCode.PROTOCOL_ERROR: 'protocol_error'>
CONFIG_ERROR = <ErrorCode.CONFIG_ERROR: 'config_error'>
DAEMON_SHUTTING_DOWN = <ErrorCode.DAEMON_SHUTTING_DOWN: 'daemon_shutting_down'>
UNAVAILABLE_MESSAGE = 'URL unavailable: it may have failed content validation or been flagged as unsafe.'
class GatewayError(builtins.Exception):
28class GatewayError(Exception):
29    """Base typed failure crossing orchestration boundaries."""
30
31    def __init__(
32        self,
33        code: ErrorCode,
34        message: str,
35        *,
36        reason: str | None = None,
37    ) -> None:
38        super().__init__(message)
39        self.code = code
40        self.message = message
41        self.reason = reason

Base typed failure crossing orchestration boundaries.

GatewayError( code: ErrorCode, message: str, *, reason: str | None = None)
31    def __init__(
32        self,
33        code: ErrorCode,
34        message: str,
35        *,
36        reason: str | None = None,
37    ) -> None:
38        super().__init__(message)
39        self.code = code
40        self.message = message
41        self.reason = reason
code
message
reason
class InputFailure(GatewayError):
44class InputFailure(GatewayError):
45    """Invalid user input or request-state combination."""

Invalid user input or request-state combination.

class ExecutionFailure(GatewayError):
48class ExecutionFailure(GatewayError):
49    """Dependency or execution-path failure."""

Dependency or execution-path failure.

class ProtocolFailure(ExecutionFailure):
52class ProtocolFailure(ExecutionFailure):
53    """Malformed local or provider protocol data."""

Malformed local or provider protocol data.

class ConfigFailure(GatewayError):
56class ConfigFailure(GatewayError):
57    """Invalid daemon startup configuration."""

Invalid daemon startup configuration.

class ParserFailure(ExecutionFailure):
60class ParserFailure(ExecutionFailure):
61    """Restricted parser rejected an execution result."""
62
63    def __init__(self, message: str) -> None:
64        super().__init__(ErrorCode.PROTOCOL_ERROR, message)

Restricted parser rejected an execution result.

ParserFailure(message: str)
63    def __init__(self, message: str) -> None:
64        super().__init__(ErrorCode.PROTOCOL_ERROR, message)
Inherited Members
GatewayError
code
message
reason
class DaemonUnavailable(builtins.Exception):
67class DaemonUnavailable(Exception):
68    """The local daemon socket is missing or refusing connections."""

The local daemon socket is missing or refusing connections.