Exceptions API

The exceptions module provides custom exceptions for the USDA FDC client.

FdcApiError

class usda_fdc.exceptions.FdcApiError[source]

Bases: Exception

Base exception for all FDC API errors.

FdcAuthError

class usda_fdc.exceptions.FdcAuthError[source]

Bases: FdcApiError

Exception raised when authentication fails.

FdcRateLimitError

class usda_fdc.exceptions.FdcRateLimitError[source]

Bases: FdcApiError

Exception raised when the API rate limit is exceeded.

FdcTimeoutError

class usda_fdc.exceptions.FdcTimeoutError[source]

Bases: FdcApiError

Exception raised when a request to the FDC API times out.

Distinct from a generic FdcApiError so callers can tell “slow” from “broken” — a timeout is usually worth retrying, a 400 is not.

FdcValidationError

class usda_fdc.exceptions.FdcValidationError[source]

Bases: FdcApiError

Exception raised when input validation fails.

FdcResourceNotFoundError

class usda_fdc.exceptions.FdcResourceNotFoundError[source]

Bases: FdcApiError

Exception raised when a requested resource is not found.