# `QuackDB.Error`
[🔗](https://github.com/elixir-vibe/quackdb/blob/main/lib/quack_db/error.ex#L1)

Structured error returned by the QuackDB client.

When DuckDB returns an `errors_as_json` payload, `metadata` includes
`:exception_type` and `:exception_message`. The original `message` is preserved,
including any native-append prefix. QuackDB does not enable this server setting
automatically or infer constraint names from error text.

# `code`

```elixir
@type code() :: atom()
```

# `source`

```elixir
@type source() :: :client | :server | :transport | :protocol
```

# `t`

```elixir
@type t() :: %QuackDB.Error{
  __exception__: term(),
  code: code(),
  connection_id: String.t() | nil,
  message: String.t(),
  metadata: map(),
  query: iodata() | nil,
  retriable?: boolean(),
  source: source()
}
```

# `disconnect?`

```elixir
@spec disconnect?(t()) :: boolean()
```

Returns whether the error means the server dropped the connection, so the
client must reconnect: its heartbeat lease expired or its database died.

# `exception_type`

```elixir
@spec exception_type(t()) :: String.t() | nil
```

Returns DuckDB's exception type for a server error, such as `"Catalog"` or
`"Constraint"`, or `nil` when the error did not come from the server.

# `new`

```elixir
@spec new(code(), String.t(), Keyword.t()) :: t()
```

# `server`

```elixir
@spec server(struct() | String.t()) :: t()
```

Builds a server error from a Quack error response or a bare message.

The code is `:query_cancelled`, `:transaction_conflict`,
`:connection_expired`, `:connection_invalidated`, or `:server_error`.

---

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