Errors
The exception hierarchy and the normalized ErrorKind classification.
Exception hierarchy and error kinds (ADR-0009, as amended).
Every class maps 1:1 to an ErrorKind value (class minus Error,
SCREAMING_SNAKE). ProviderError is the unclassified catch-all and hosts
the one nested leaf, EmptySolutionError (ADR-0040).
Behavioral discipline enforced at call sites (not in these classes):
- Wrapped causes always chain:
raise ... from cause. - Wrong-provider routing raises
TypeErrorpre-flight, no network (ADR-0045); there is no dedicated exception for it. - No
SolveCancelledError(ADR-0016) and noUnknownTaskError(ADR-0050) — by construction.
ErrorKind
Bases: Enum
Classification of library errors (ADR-0009, as amended).
UnicaptchaError
Bases: Exception
Base of the library error hierarchy.
Carries the error kind and the verbatim provider response body
(raw_response) when one exists.
NetworkError
AuthenticationError
InsufficientBalanceError
UnsupportedChallengeError
Bases: UnicaptchaError
The provider does not support this operation for this captcha kind.
Raised for server-side task-type rejections and client-side pre-flight
coverage gaps alike (ADR-0057). Never for wrong-provider routing
(TypeError) or unknown task ids (TaskStatus.UNKNOWN).
InvalidChallengeError
TaskTimeoutError
RateLimitError
ServiceBusyError
NoSolutionError
InvalidConfigError
Bases: UnicaptchaError
A configuration value was explicitly set to an invalid value.
None is always valid ("unspecified", ADR-0043); only explicit bad
values raise (ADR-0042).
ClientClosedError
NoCaptchaDetectedError
ProviderError
Bases: UnicaptchaError
Unclassified provider error.
Also raised for malformed responses (HTTP 200, unparseable or
wrong-shape body) with the parse failure chained as __cause__ and
raw_response preserved (ADR-0040, ADR-0058).
EmptySolutionError
Bases: ProviderError
A "solved" response whose solution payload was empty (ADR-0040).
Subclass of ProviderError with its own kind: empty answers are
typically transient worker failures and may be retried/rerouted,
unlike generic garbage.
error_from_kind
error_from_kind(kind, message, raw_response=b'')
Construct the exception leaf for an ErrorKind (provider mapping).
Public so third-party adapters can raise mapped provider errors
without touching unicaptcha._internal (ADR-0041 boundary).