Errors¶
sppyte.errors ¶
Exceptions raised by sppyte.
Hierarchy:
SppyteError
├── ConfigurationError (also a ValueError)
├── SessionError (kept for compatibility; no longer raised)
├── ResponseFormatError
└── SharePointError (also a requests.HTTPError)
└── AuthError
SharePointError carries the parsed SharePoint error body, so a failed call
reads HTTP 400: Column 'Foo' does not exist instead of
400 Client Error: Bad Request for url: .... Because it subclasses
requests.HTTPError, existing except HTTPError handlers keep working.
SppyteError ¶
Bases: Exception
Base class for every sppyte exception.
ConfigurationError ¶
Bases: SppyteError, ValueError
Raised when Site is constructed with malformed options.
SessionError ¶
Bases: SppyteError
Raised when an HTTP session is not available.
Kept for compatibility with 0.x; sessions are now created on demand, so this is no longer raised.
ResponseFormatError ¶
Bases: SppyteError
Raised when an expected field is missing from a SharePoint JSON payload.
SharePointErrorDetails
dataclass
¶
SharePointErrorDetails(code: str | None = None, message: str | None = None)
The error object SharePoint returns in a failed response body.
SharePointError ¶
SharePointError(response: Response)
Bases: SppyteError, HTTPError
Raised when SharePoint answers with a non-2xx status.
Attributes:
| Name | Type | Description |
|---|---|---|
status |
int
|
HTTP status code. |
code |
str | None
|
SharePoint error code from the response body, if present. |
message |
str | None
|
SharePoint error message from the response body, if present. |
retry_after |
float | None
|
Seconds the server asked clients to wait ( |
response |
float | None
|
The underlying |
AuthError ¶
AuthError(response: Response)
Bases: SharePointError
Raised for 401/403: bad credentials, a rejected handshake, or an expired/missing request digest.
raise_for_status ¶
raise_for_status(response: Response) -> None
Raise AuthError for 401/403 and SharePointError for any other 4xx/5xx.
parse_sharepoint_error ¶
parse_sharepoint_error(body: Any) -> SharePointErrorDetails | None
Extract SharePoint's error object from a response body.
Handles both the odata=verbose shape
({"error": {"code": ..., "message": {"value": ...}}}) and the
odata=nometadata / minimalmetadata shape ({"odata.error": ...}).
Returns:
| Type | Description |
|---|---|
SharePointErrorDetails | None
|
The parsed details, or |
parse_retry_after ¶
parse_retry_after(value: str | None, now: datetime | None = None) -> float | None
Parse a Retry-After header given as delay-seconds or an HTTP date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str | None
|
The raw header value, or |
required |
now
|
datetime | None
|
Reference time for HTTP dates; defaults to the current UTC time. |
None
|
Returns:
| Type | Description |
|---|---|
float | None
|
Seconds to wait (never negative), or |