REST Client

SignalWireRestError

View as MarkdownOpen in Claude

Custom exception class for REST API errors. Extends Python’s built-in Exception class. Raised when an HTTP request to the SignalWire REST API returns a non-success status code.

1from signalwire.rest import SignalWireRestError

Properties

status_code
int

HTTP status code returned by the API (e.g., 404, 422, 500).

body
str | dict

Response body from the API (JSON dict if parseable, otherwise raw string).

url
str

The URL path that was requested.

method
str

The HTTP method used ("GET", "POST", "PUT", "PATCH", "DELETE").

Example

1from signalwire.rest import RestClient, SignalWireRestError
2
3client = RestClient(
4 project="your-project-id",
5 token="your-api-token",
6 host="your-space.signalwire.com",
7)
8
9try:
10 client.phone_numbers.get("nonexistent-id")
11except SignalWireRestError as e:
12 print(f"HTTP {e.status_code}: {e.body}")
13 print(f"Request: {e.method} {e.url}")