# `ZenWebsocket.Examples.Docs.ErrorHandling`
[🔗](https://github.com/ZenHive/zen_websocket/blob/v0.4.2/lib/zen_websocket/examples/docs/error_handling.ex#L1)

Error handling and retry patterns from Examples.md

# `state`

```elixir
@type state() :: %{
  client: pid() | nil,
  url: String.t(),
  opts: keyword(),
  retry_count: non_neg_integer()
}
```

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `get_state`

```elixir
@spec get_state() :: state()
```

Returns the current state of the error handler.

## Returns
The internal state map including connection status and retry count.

# `send_message`

```elixir
@spec send_message(binary()) :: :ok | {:ok, map()} | {:error, term()}
```

Sends a message through the WebSocket connection.

## Parameters
- `message` - Message to send (must be a binary — use `Jason.encode!/1` for maps)

## Returns
- `:ok` on success
- `{:error, :not_connected}` if not connected
- `{:error, {:not_connected, reason}}` if client is disconnected or process is down

# `start_link`

```elixir
@spec start_link(
  String.t(),
  keyword()
) :: GenServer.on_start()
```

Starts a GenServer that manages a WebSocket connection with automatic retry.

## Parameters
- `url` - WebSocket URL to connect to
- `opts` - Connection options

## Returns
`{:ok, pid}` on success or `{:error, reason}` on failure.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
