Skip to content

Exceptions Reference

Exception Hierarchy

MCSRRankedError
├── APIError
│   ├── APIStatusError
│   │   ├── BadRequestError
│   │   ├── AuthenticationError
│   │   ├── NotFoundError
│   │   └── RateLimitError
│   └── APIConnectionError
│       └── APITimeoutError

Base Exceptions

MCSRRankedError

Base exception for all MCSR Ranked SDK errors.

APIError

Base exception for API-related errors.


HTTP Status Exceptions

APIStatusError

Exception raised when the API returns an error status code.

BadRequestError

Exception raised for 400 Bad Request responses.

AuthenticationError

Exception raised for 401 Unauthorized responses.

NotFoundError

Exception raised for 404 Not Found responses.

RateLimitError

Exception raised for 429 Too Many Requests responses.


Connection Exceptions

APIConnectionError

Exception raised when a connection error occurs.

APITimeoutError

Exception raised when a request times out.


Usage Examples

Catching all SDK errors

from mcsrranked import MCSRRankedError

try:
    user = mcsrranked.users.get("someone")
except MCSRRankedError as e:
    print(f"SDK error: {e}")

Catching specific errors

from mcsrranked import NotFoundError, RateLimitError

try:
    user = mcsrranked.users.get("nonexistent")
except NotFoundError as e:
    print(f"User not found: {e.status_code}")
except RateLimitError as e:
    print(f"Rate limited: {e.status_code}")

Accessing error details

from mcsrranked import APIStatusError

try:
    user = mcsrranked.users.get("invalid")
except APIStatusError as e:
    print(f"Status: {e.status_code}")
    print(f"Message: {e.message}")
    print(f"Body: {e.body}")