Перейти к содержанию

Исключения

cdekx.exceptions.CdekxError

Bases: Exception

Base exception of the library.

cdekx.exceptions.ApiError

Bases: CdekxError

The CDEK API returned an error (HTTP 4xx/5xx).

Attributes:

Name Type Description
status_code

HTTP status of the response.

errors tuple[ApiErrorDetail, ...]

parsed entries of the errors array from the response body.

body

the response body as-is (a dict, or str when it is not JSON).

request_id

X-Request-Id/traceparent from the headers, when present — handy when contacting CDEK support.

codes property

CDEK error codes (error_validate_... and similar).

has_code(code)

Check whether a specific error code is present.

cdekx.exceptions.AuthError

Bases: ApiError

401/403 — bad credentials, or an expired/revoked token.

cdekx.exceptions.NotFoundError

Bases: ApiError

404 — entity not found.

cdekx.exceptions.ValidationError

Bases: ApiError

400/422 — the request failed validation on the CDEK side.

cdekx.exceptions.RateLimitError

Bases: ApiError

429 — rate limit exceeded (see retry_after).

cdekx.exceptions.ServerError

Bases: ApiError

5xx — an error on the CDEK side.

cdekx.exceptions.TransportError

Bases: CdekxError

Network error or timeout after retries have been exhausted.

cdekx.exceptions.TimeoutExceeded

Bases: TransportError

The request timed out.

cdekx.exceptions.ConfigError

Bases: CdekxError, ValueError

Invalid client configuration (missing credentials, bad URL, and so on).

cdekx.endpoints.base.ResponseParseError

Bases: CdekxError, ValueError

The API response does not match the expected schema.

Raised when CDEK has changed the contract. The exception keeps the raw data (raw) so the problem can be diagnosed and reported.