Errors
Every endpoint can return a non-2xx status. Neither SDK returns error status codes silently -- they always raise/throw, so a successful call means a 2xx response.
Status codes
| Field | Type | Description |
|---|---|---|
| 400 | Bad Request | The payload failed validation. Check the response body for details. |
| 401 | Unauthorized | Missing, invalid, or expired bearer token. Both SDKs handle token refresh automatically, so this usually means bad credentials. |
| 403 | Forbidden | Token is valid but not permitted to perform this action. |
| 404 | Not Found | Returned by GET/PATCH endpoints for a resource that doesn't exist (e.g. an unknown company id). |
| 500 | Internal Server Error | Something went wrong on the API side. Safe to retry. |
Error response bodies aren't formally schema'd by the API, so both SDKs surface the raw parsed body alongside the status code rather than trying to force it into a fixed shape.
Exception / error classes
from mca2_sdk import (
MCA2Error, # base class for everything the SDK raises
MCA2ConnectionError, # network failure, no HTTP response at all
MCA2APIError, # base for any non-2xx response; has .status_code, .response_body, .request_url
MCA2ValidationError, # 400
MCA2AuthenticationError, # 401
MCA2ForbiddenError, # 403
MCA2NotFoundError, # 404
MCA2ServerError, # 5xx
)Handling errors
from mca2_sdk import MCA2APIError, MCA2ConnectionError
try:
client.deals.get("does-not-exist")
except MCA2APIError as exc:
print(exc.status_code, exc.response_body)
except MCA2ConnectionError as exc:
print("network problem:", exc)Note
client.deals.add_note() / client.deals.addNote() also validates the 1000-character note limit locally and raises MCA2ValidationError before making a network request if it's exceeded.