Skip to content

Errors

Exception classes raised by the library.

GrocyError

Raised when the Grocy API returns an HTTP 4xx or 5xx response.

from grocy.errors import GrocyError

try:
    product = grocy.product(99999)
except GrocyError as e:
    print(f"HTTP {e.status_code}: {e.message}")

GrocyError(response)

Bases: Exception

Exception raised when the Grocy API returns an error response.

Attributes:

Name Type Description
status_code int

HTTP status code from the response.

message str

Error message from the API, if available.

status_code property

HTTP status code from the error response.

message property

Error message from the API.

is_client_error property

True if this is a 4xx client error.

is_server_error property

True if this is a 5xx server error.