gfwapiclient.exceptions.http

Global Fishing Watch (GFW) API Python Client - HTTP Exceptions.

This module defines custom exception classes for handling errors that occur when interacting with the Global Fishing Watch API.

It includes: - APIError: Base exception for general API errors. - APIStatusError: Exception for HTTP 4xx and 5xx responses. - APIConnectionError: Exception for network connection issues. - APITimeoutError: Exception for request timeouts. - Subclasses for specific HTTP status codes (e.g., NotFoundError, RateLimitError).

Module Contents

Data

API

gfwapiclient.exceptions.http.__all__ = ['APIConnectionError', 'APIError', 'APIStatusError', 'APITimeoutError', 'AuthenticationError', 'BadG...
gfwapiclient.exceptions.http.API_CONNECTION_ERROR_MESSAGE: Final[str] = 'Connection error.'
gfwapiclient.exceptions.http.API_TIMEOUT_ERROR_MESSAGE: Final[str] = 'Request timed out.'
exception gfwapiclient.exceptions.http.APIError(message: str, request: httpx.Request, *, body: Optional[Any] = None)

Bases: gfwapiclient.exceptions.base.GFWAPIClientError

Base exception for general API errors.

This exception represents general errors encountered while interacting with the Global Fishing Watch (GFW) API.

Attributes:
request (httpx.Request):

The HTTP request that triggered the error.

body (Optional[Any]):

The API response body, if available.

  • If the API response is valid JSON, body contains the decoded JSON object.

  • If the response is not valid JSON, body contains the raw response content.

  • If no response is associated with the error, body is None.

See Also:

GFW API documentation on error codes: <https://globalfishingwatch.org/our-apis/documentation#errors-codes>

Initialization

Initialize a new APIError exception.

Args:
message (str):

The error message.

request (httpx.Request):

The HTTP request that caused the error.

body (Optional[Any], default=None):

The API response body, if available.

request: httpx.Request = None
body: Optional[Any] = None
__str__() str

Return a string representation of the error.

__repr__() str

Return the canonical string representation of the error.

exception gfwapiclient.exceptions.http.APIStatusError(message: str, *, response: httpx.Response, body: Optional[Any] = None)

Bases: gfwapiclient.exceptions.http.APIError

Exception raised for API HTTP response errors (4xx or 5xx).

Attributes:
response (httpx.Response):

The HTTP response that caused the error.

status_code (int):

The HTTP status code of the response.

Initialization

Initialize a new APIStatusError exception.

Args:
message (str):

The error message.

response (httpx.Response):

The HTTP response that caused the error.

body (Optional[Any], default=None):

The API response body, if available.

response: httpx.Response = None
status_code: int = None
__repr__() str

Return the canonical string representation of the error.

exception gfwapiclient.exceptions.http.APIConnectionError(*, message: str = API_CONNECTION_ERROR_MESSAGE, request: httpx.Request)

Bases: gfwapiclient.exceptions.http.APIError

Exception raised when a connection error occurs.

Initialization

Initialize a new APIConnectionError exception.

Args:
message (str):

The error message.

request (httpx.Request):

The HTTP request that caused the error.

exception gfwapiclient.exceptions.http.APITimeoutError(request: httpx.Request)

Bases: gfwapiclient.exceptions.http.APIConnectionError

Exception raised when a request times out.

Initialization

Initialize a new APITimeoutError exception.

Args:
request (httpx.Request):

The HTTP request that timed out.

exception gfwapiclient.exceptions.http.BadRequestError(message: str, *, response: httpx.Response, body: Optional[Any] = None)

Bases: gfwapiclient.exceptions.http.APIStatusError

400 Bad Request Error.

Initialization

Initialize a new APIStatusError exception.

Args:
message (str):

The error message.

response (httpx.Response):

The HTTP response that caused the error.

body (Optional[Any], default=None):

The API response body, if available.

status_code: Literal[400] = 400
exception gfwapiclient.exceptions.http.AuthenticationError(message: str, *, response: httpx.Response, body: Optional[Any] = None)

Bases: gfwapiclient.exceptions.http.APIStatusError

401 Authentication Error.

Initialization

Initialize a new APIStatusError exception.

Args:
message (str):

The error message.

response (httpx.Response):

The HTTP response that caused the error.

body (Optional[Any], default=None):

The API response body, if available.

status_code: Literal[401] = 401
exception gfwapiclient.exceptions.http.PermissionDeniedError(message: str, *, response: httpx.Response, body: Optional[Any] = None)

Bases: gfwapiclient.exceptions.http.APIStatusError

403 Permission Denied Error.

Initialization

Initialize a new APIStatusError exception.

Args:
message (str):

The error message.

response (httpx.Response):

The HTTP response that caused the error.

body (Optional[Any], default=None):

The API response body, if available.

status_code: Literal[403] = 403
exception gfwapiclient.exceptions.http.NotFoundError(message: str, *, response: httpx.Response, body: Optional[Any] = None)

Bases: gfwapiclient.exceptions.http.APIStatusError

404 Not Found Error.

Initialization

Initialize a new APIStatusError exception.

Args:
message (str):

The error message.

response (httpx.Response):

The HTTP response that caused the error.

body (Optional[Any], default=None):

The API response body, if available.

status_code: Literal[404] = 404
exception gfwapiclient.exceptions.http.RequestTimeoutError(message: str, *, response: httpx.Response, body: Optional[Any] = None)

Bases: gfwapiclient.exceptions.http.APIStatusError

408 Request Timeout Error.

Initialization

Initialize a new APIStatusError exception.

Args:
message (str):

The error message.

response (httpx.Response):

The HTTP response that caused the error.

body (Optional[Any], default=None):

The API response body, if available.

status_code: Literal[408] = 408
exception gfwapiclient.exceptions.http.ConflictError(message: str, *, response: httpx.Response, body: Optional[Any] = None)

Bases: gfwapiclient.exceptions.http.APIStatusError

409 Conflict Error.

Initialization

Initialize a new APIStatusError exception.

Args:
message (str):

The error message.

response (httpx.Response):

The HTTP response that caused the error.

body (Optional[Any], default=None):

The API response body, if available.

status_code: Literal[409] = 409
exception gfwapiclient.exceptions.http.UnprocessableEntityError(message: str, *, response: httpx.Response, body: Optional[Any] = None)

Bases: gfwapiclient.exceptions.http.APIStatusError

422 Unprocessable Entity Error.

Initialization

Initialize a new APIStatusError exception.

Args:
message (str):

The error message.

response (httpx.Response):

The HTTP response that caused the error.

body (Optional[Any], default=None):

The API response body, if available.

status_code: Literal[422] = 422
exception gfwapiclient.exceptions.http.RateLimitError(message: str, *, response: httpx.Response, body: Optional[Any] = None)

Bases: gfwapiclient.exceptions.http.APIStatusError

429 Too Many Requests (Rate Limit) Error.

Initialization

Initialize a new APIStatusError exception.

Args:
message (str):

The error message.

response (httpx.Response):

The HTTP response that caused the error.

body (Optional[Any], default=None):

The API response body, if available.

status_code: Literal[429] = 429
exception gfwapiclient.exceptions.http.InternalServerError(message: str, *, response: httpx.Response, body: Optional[Any] = None)

Bases: gfwapiclient.exceptions.http.APIStatusError

500 Internal Server Error.

Initialization

Initialize a new APIStatusError exception.

Args:
message (str):

The error message.

response (httpx.Response):

The HTTP response that caused the error.

body (Optional[Any], default=None):

The API response body, if available.

status_code: Literal[500] = 500
exception gfwapiclient.exceptions.http.BadGatewayError(message: str, *, response: httpx.Response, body: Optional[Any] = None)

Bases: gfwapiclient.exceptions.http.APIStatusError

502 Bad Gateway Error.

Initialization

Initialize a new APIStatusError exception.

Args:
message (str):

The error message.

response (httpx.Response):

The HTTP response that caused the error.

body (Optional[Any], default=None):

The API response body, if available.

status_code: Literal[502] = 502
exception gfwapiclient.exceptions.http.ServiceUnavailableError(message: str, *, response: httpx.Response, body: Optional[Any] = None)

Bases: gfwapiclient.exceptions.http.APIStatusError

503 Service Unavailable Error.

Initialization

Initialize a new APIStatusError exception.

Args:
message (str):

The error message.

response (httpx.Response):

The HTTP response that caused the error.

body (Optional[Any], default=None):

The API response body, if available.

status_code: Literal[503] = 503
exception gfwapiclient.exceptions.http.GatewayTimeoutError(message: str, *, response: httpx.Response, body: Optional[Any] = None)

Bases: gfwapiclient.exceptions.http.APIStatusError

504 Gateway Timeout Error.

Initialization

Initialize a new APIStatusError exception.

Args:
message (str):

The error message.

response (httpx.Response):

The HTTP response that caused the error.

body (Optional[Any], default=None):

The API response body, if available.

status_code: Literal[504] = 504