QuackDB.Error exception (quackdb v0.7.0)

Copy Markdown View Source

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.

Summary

Functions

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

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.

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

Types

code()

@type code() :: atom()

source()

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

t()

@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()
}

Functions

disconnect?(error)

@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(error)

@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(code, message, options \\ [])

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

server(response)

@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.