Skip to content

Python SDK errors ​

Every failed call raises SocifyrError or a subclass. Each exception has .message and .status (the HTTP status, or None for network failures).

Which exceptions does the SDK raise? ​

ClassHTTP status
ValidationError400
AuthenticationError401 and 403
UsageLimitError402
NotFoundError404
RateLimitError429
SocifyrErroranything else, including 409, 422, 5xx and network errors

The Python SDK has no separate permission class. A 403 raises AuthenticationError. The TypeScript SDK has PermissionError for 403, see TypeScript errors.

All classes import from the package root:

python
from socifyr import (
    Socifyr, SocifyrError, ValidationError, AuthenticationError,
    UsageLimitError, NotFoundError, RateLimitError,
)

How do I handle errors? ​

python
client = Socifyr()

try:
    client.uploads.text(connections=["nonexistent-slug"], text="hi")
except ValidationError as err:
    print(err.status, err.message)  # 400 Connection "nonexistent-slug" not found
except RateLimitError:
    print("slow down")
except UsageLimitError:
    print("plan limit reached")
except SocifyrError as err:
    print("failed:", err.status, err.message)

How are messages built? ​

The message is the error field of the API error envelope. If the API returns an array of validation messages, the SDK joins them with "; ". If the body has no usable error, the message is Request failed with status <status>.

RateLimitError does not expose the Retry-After value. Wait a fixed delay, such as 60 seconds, then retry.

What about platform failures? ​

A post can be accepted and then fail on one platform. That does not raise. Read it from the status:

python
status = client.uploads.get_status(ack["requestId"])
for ch in status["channels"]:
    result = ch.get("result") or {}
    if result.get("status") == "failed":
        print(ch["platform"], result.get("error"))

FAQ ​

Why is status None? ​

The request never got a response (DNS, TLS, timeout). The message is the underlying requests error text.

Does ValueError come from the SDK? ​

Only from the constructor, when no API key is available.

Next steps ​