Skip to content

WFRMLS exceptions and failure behavior

All custom exceptions inherit from WFRMLSError. Their optional status_code and response_data attributes describe HTTP failures; local failures may leave both as None.

HTTP response mapping

The shared BaseClient maps response codes as follows:

Condition Exception or return value
200 or 201 Parsed JSON; invalid JSON becomes {"message": response.text}
204 Empty dictionary
400 ValidationError
401 AuthenticationError
404 NotFoundError
429 RateLimitError
500–599 ServerError
Other statuses, including 403 WFRMLSError
Requests transport exception in shared requests NetworkError

Missing credentials raise AuthenticationError when a BaseClient or service client is constructed. WFRMLSClient() defers that construction until service access. Nonnumeric property lookup strings and unsupported radius/polygon calls raise ValidationError locally. An empty wrapped single-property result raises NotFoundError locally.

Catch expected failures

With WFRMLS_BEARER_TOKEN configured:

from wfrmls import NotFoundError, WFRMLSClient, WFRMLSError

client = WFRMLSClient()
try:
    listing = client.property.get_property("12345")
    print(listing.get("ListingId"))
except NotFoundError:
    print("No property record was returned.")
except WFRMLSError as error:
    print(type(error).__name__, error.status_code)

Do not log tokens or complete response payloads containing personal data. The exception's message is inherited from Exception; there is no custom message attribute.

Failure paths that need separate handling

  • get_metadata() uses a direct Requests call. Non-200 responses raise generic WFRMLSError without shared HTTP attributes; transport exceptions propagate as Requests exceptions.
  • Analytics helpers catch exceptions and return {"error": ...} instead of raising them.
  • get_all_properties_paginated() catches request failures and returns partial data without an error marker.
  • DeletedClient.get_all_deleted_for_sync() suppresses per-resource failures, retaining empty lists for those resources without an error marker.
  • Incorrect or duplicate Python keyword arguments can raise TypeError; that is not a WFRMLSError subclass.

The client does not implement automatic retries, backoff, token refresh, or rate-limit scheduling. Design those policies around your application requirements.

Generated exception definitions

Custom exceptions for WFRMLS API wrapper.

Classes

AuthenticationError

AuthenticationError(
    message: str,
    status_code: Optional[int] = None,
    response_data: Optional[Dict[str, Any]] = None,
)

Bases: WFRMLSError

Raised for missing service credentials or a shared HTTP 401 response.

The facade defers missing-credential errors until service construction.

NetworkError

NetworkError(
    message: str,
    status_code: Optional[int] = None,
    response_data: Optional[Dict[str, Any]] = None,
)

Bases: WFRMLSError

Raised when a shared request catches a Requests transport exception.

The separate metadata request propagates its Requests exceptions directly.

NotFoundError

NotFoundError(
    message: str,
    status_code: Optional[int] = None,
    response_data: Optional[Dict[str, Any]] = None,
)

Bases: WFRMLSError

Raised for shared HTTP 404 responses or an empty wrapped property lookup.

RateLimitError

RateLimitError(
    message: str,
    status_code: Optional[int] = None,
    response_data: Optional[Dict[str, Any]] = None,
)

Bases: WFRMLSError

Raised for a shared HTTP 429 response.

The package does not automatically retry or schedule requests after this error.

ServerError

ServerError(
    message: str,
    status_code: Optional[int] = None,
    response_data: Optional[Dict[str, Any]] = None,
)

Bases: WFRMLSError

Raised for shared HTTP responses with status codes from 500 through 599.

ValidationError

ValidationError(
    message: str,
    status_code: Optional[int] = None,
    response_data: Optional[Dict[str, Any]] = None,
)

Bases: WFRMLSError

Raised for shared HTTP 400 responses or explicit local input checks.

Examples include nonnumeric property keys and disabled geospatial methods.

WFRMLSError

WFRMLSError(
    message: str,
    status_code: Optional[int] = None,
    response_data: Optional[Dict[str, Any]] = None,
)

Bases: Exception

Base custom exception with optional status_code and response_data attributes.

Local failures may omit both attributes. Python argument errors and direct metadata transport errors are not necessarily wrapped in this hierarchy.

Parameters:

Name Type Description Default
message str

Error message describing what went wrong

required
status_code Optional[int]

HTTP status code from the API response

None
response_data Optional[Dict[str, Any]]

Raw response data from the API for debugging

None

Methods:

See HTTP client behavior and response conventions for request and result details.