***

title: RelayError
slug: /reference/python/relay/relay-error
description: Exception raised when the RELAY server returns an error.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

Exception raised when the RELAY server returns an error response. Inherits from
Python's built-in `Exception`. The string representation follows the format
`"RELAY error {code}: {message}"`.

```python
from signalwire.relay.client import RelayError
```

## **Properties**

<ParamField path="code" type="int" toc={true}>
  Numeric error code returned by the RELAY server.
</ParamField>

<ParamField path="message" type="str" toc={true}>
  Human-readable error description returned by the RELAY server.
</ParamField>

## **Examples**

### Catch a RELAY error

```python
from signalwire.relay import RelayClient
from signalwire.relay.client import RelayError

client = RelayClient(
    project="your-project-id",
    token="your-api-token",
    host="your-space.signalwire.com",
    contexts=["default"],
)

@client.on_call
async def handle_call(call):
    try:
        await call.connect(devices=[[{"type": "phone", "params": {"to_number": "+15559876543"}}]])
    except RelayError as e:
        print(f"Error {e.code}: {e.message}")
        await call.hangup()

client.run()
```