Appearance
Error Handling
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of modulos_client.APIConnectionError is raised.
When the API returns a non-success status code (that is, 4xx or 5xx response), a subclass of modulos_client.APIStatusError is raised, containing status_code and response properties.
All errors inherit from modulos_client.APIError.
python
import modulos_client
from modulos_client import Modulos
client = Modulos()
try:
metrics = client.testing.logs.get_metrics(project_id)
except modulos_client.APIConnectionError as e:
print("The server could not be reached")
print(e.__cause__) # an underlying Exception, likely raised within httpx.
except modulos_client.APIStatusError as e:
print("Another non-200-range status code was received")
print(e.status_code)
print(e.response)Error Codes
| Status Code | Error Type |
|---|---|
| 400 | BadRequestError |
| 401 | AuthenticationError |
| 403 | PermissionDeniedError |
| 404 | NotFoundError |
| 422 | UnprocessableEntityError |
| >=500 | InternalServerError |
| N/A | APIConnectionError |