Skip to content

Exceptions

Exception types raised by the kxi library.

All HTTP-mapped exceptions carry the original httpx.HTTPStatusError response and request for inspection.

HTTP status codes are automatically mapped to typed exceptions:

Status Exception
400 BadRequestError
401 UnauthorizedError
403 ForbiddenError
404 NotExistError
409 ConflictError
5xx ServerError
Example
from kxi.exceptions import NotExistError, ConflictError

try:
    svc.get("missing-entity")
except NotExistError as e:
    print(f"Not found: {e}")
except ConflictError as e:
    print(f"Already exists: {e}")

Classes:

  • BadRequestError – Raised when the server rejects a malformed or invalid request (HTTP 400).
  • ClientEnrolError – Raised when client enrolment via the Client Controller fails unexpectedly.
  • ClientError – Raised for general client-side errors not covered by HTTP status codes.
  • ClientNotFoundException – Raised when a Keycloak client cannot be found by its client ID.
  • ClientQueryError – Raised when a client query request fails, carrying kdb+ error details.
  • ConflictError – Raised when a resource with the same name or ID already exists (HTTP 409).
  • ConflictException – Base class for conflict errors.
  • ForbiddenError – Raised when the authenticated user lacks permission for the request (HTTP 403).
  • InvalidParameter – Raised when a supplied parameter value does not meet API expectations.
  • MissingParameter – Raised when a required parameter was not provided.
  • NotExistError – Raised when a requested resource does not exist (HTTP 404).
  • NotFoundException – Base class for not-found errors.
  • ServerError – Raised on server-side errors (HTTP 500–504).
  • TokenRetrievalFailure – Raised when an OAuth2 access token could not be obtained.
  • UnauthorizedError – Raised when a request lacks valid authentication credentials (HTTP 401).

BadRequestError

Bases: _CustomHTTPStatusError

Raised when the server rejects a malformed or invalid request (HTTP 400).

ClientEnrolError

Bases: Exception

Raised when client enrolment via the Client Controller fails unexpectedly.

ClientError

Bases: Exception

Raised for general client-side errors not covered by HTTP status codes.

ClientNotFoundException

Bases: Exception

Raised when a Keycloak client cannot be found by its client ID.

ClientQueryError

ClientQueryError(*args, result=None, **kwargs)

Bases: BadRequestError

Raised when a client query request fails, carrying kdb+ error details.

The info attribute contains parsed error metadata from the query response header, including the ai field with the kdb+ error message.

Attributes:

  • info – Dict of error metadata extracted from the query response.
  • qinfo (Optional[K]) – Raw kdb+ error object (pykx K type), if available.

Functions:

resolve_qinfo

resolve_qinfo()

Resolve qinfo and fill up self.info.

ConflictError

Bases: _CustomHTTPStatusError, ConflictException

Raised when a resource with the same name or ID already exists (HTTP 409).

ConflictException

Bases: Exception

Base class for conflict errors.

Extended by ConflictError for HTTP-backed conflicts.

ForbiddenError

Bases: _CustomHTTPStatusError

Raised when the authenticated user lacks permission for the request (HTTP 403).

InvalidParameter

Bases: Exception

Raised when a supplied parameter value does not meet API expectations.

MissingParameter

Bases: Exception

Raised when a required parameter was not provided.

NotExistError

Bases: _CustomHTTPStatusError, NotFoundException

Raised when a requested resource does not exist (HTTP 404).

NotFoundException

Bases: Exception

Base class for not-found errors.

Extended by NotExistError for HTTP-backed lookups.

ServerError

Bases: _CustomHTTPStatusError

Raised on server-side errors (HTTP 500–504).

TokenRetrievalFailure

Bases: Exception

Raised when an OAuth2 access token could not be obtained.

UnauthorizedError

Bases: _CustomHTTPStatusError

Raised when a request lacks valid authentication credentials (HTTP 401).

Back to top