InfluxElixir.StreamError exception (InfluxElixir v0.1.18)

Copy Markdown View Source

Raised while consuming a streaming query result when the request cannot produce rows.

Streaming query functions such as InfluxElixir.query_sql_stream/3 return an Enumerable.t(), so they cannot return an {:error, reason} tuple the way InfluxElixir.query_sql/3 does. Instead, error classes are surfaced by raising this exception at consumption time — the moment the stream is enumerated — so failures are never silently swallowed as "zero rows".

Kinds

  • :no_database — no database was resolved from opts or the connection
  • :http_status — the server responded with a non-success status; the :status and :body fields carry the response
  • :transport — a Finch/Mint transport error occurred; :reason carries it
  • :decode — a JSONL line could not be decoded as JSON; :reason carries the decode error

Example

try do
  conn
  |> InfluxElixir.query_sql_stream("SELECT * FROM cpu")
  |> Enum.to_list()
rescue
  e in InfluxElixir.StreamError ->
    Logger.error("stream failed: " <> Exception.message(e))
    {:error, e}
end

Summary

Types

kind()

@type kind() :: :no_database | :http_status | :transport | :decode

t()

@type t() :: %InfluxElixir.StreamError{
  __exception__: true,
  body: term(),
  kind: kind(),
  message: String.t(),
  reason: term(),
  status: non_neg_integer() | nil
}