RestError
Custom error class for REST API errors. Extends JavaScript’s built-in Error
class. Thrown when an HTTP request to the SignalWire REST API returns a non-success
status code, or when the request never reaches the server. The name property is
"RestError", or "RestTransportError" for the transport subclass below.
Also exported as SignalWireRestError to match the Python SDK class name.
Properties
statusCode
HTTP status code returned by the API (e.g., 404, 422, 500). null for
a RestTransportError, where no response was received.
body
Response body from the API. A SignalWireErrorBody object (code,
message, and optional more_info and status) when the response was valid
JSON; otherwise the raw text. For a RestTransportError, the underlying
transport error message.
url
The URL that was requested.
method
The HTTP method used ("GET", "POST", "PUT", "PATCH", "DELETE").
headers
Response headers from the failed request. null for a transport failure.
requestId
The platform request ID read from the response headers, or null when
absent. Quote it when you contact support about a failed request.
name
"RestError", or "RestTransportError" for a transport failure.
message
Human-readable summary: "{method} {url} returned {statusCode}: {body}" for
an HTTP error, or "{method} {url} failed to reach the server: {body}" for a
transport failure. Followed by (request-id: ...) when a request ID is
available.
RestTransportError
Thrown when a request never reaches a response: a connection refused, a DNS
failure, a TLS error, or a RequestOptions timeout. It extends RestError, so
one catch (e instanceof RestError) handles HTTP errors and transport failures
alike. statusCode, headers, and requestId are null, and body holds the
underlying transport error message.
Also exported as SignalWireRestTransportError.