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:statusand:bodyfields carry the response:invalid_request— the request could not be built from the arguments (options that are not a keyword list, a parameter or text JSON cannot carry, a keyword connection with neither:finch_namenor:name);:reasoncarries the errorInfluxElixir.query_sql/3returns for the same call:transport— a Finch/Mint transport error occurred;:reasoncarries it:decode— a JSONL line could not be decoded as JSON, or is JSON but not an object;:reasoncarries the decode error, or{:unexpected_json, value}:unsupported— the operation is not supported by the connection's profile (raised byInfluxElixir.Client.Localfor capability parity)
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
Functions
Builds an Enumerable.t() that raises this error the moment it is enumerated.
Types
@type kind() ::
:no_database
| :invalid_request
| :http_status
| :transport
| :decode
| :unsupported
@type t() :: %InfluxElixir.StreamError{ __exception__: true, body: term(), kind: kind(), message: String.t(), reason: term(), status: non_neg_integer() | nil }
Functions
@spec stream(keyword()) :: Enumerable.t()
Builds an Enumerable.t() that raises this error the moment it is enumerated.
Streaming query functions return an Enumerable.t(), so a pre-request failure
(no database, unsupported operation, an already-known error) cannot be
returned as an {:error, reason} tuple. Wrapping it in this stream defers the
raise to consumption time — matching the lazy semantics of a real streamed
response — instead of yielding an empty list that looks like "zero rows".
opts are the same keyword options accepted by exception/1
(:kind, :status, :body, :reason).