Huginn.Error exception (Huginn v0.6.0)

Copy Markdown View Source

The single error type returned (and raised) by Huginn.

Every public function returns {:error, %Huginn.Error{}} on failure, and the bang/streaming variants raise it. Match on :reason to branch:

:reasonMeaning:code
:serverClickHouse rejected or failed the queryClickHouse error code
:connectionNo usable connection (pool not ready, refused, unavailable)gRPC status, if any
:timeoutThe request deadline expiredgRPC status, if any
:grpcAny other gRPC-level failuregRPC status
:decodeThe server output could not be parsed in the requested formatnil
:unexpected_replyThe server replied with something that is not a Resultnil
:not_configuredNo pool is configured under the requested namenil

:details carries the original term (the ClickHouse exception, the GRPC.RPCError, the decoder error, ...) for logging and debugging.

Summary

Functions

Normalizes any failure term produced by the transport or the server into a Huginn.Error. An existing Huginn.Error is returned unchanged.

Types

reason()

@type reason() ::
  :server
  | :connection
  | :timeout
  | :grpc
  | :decode
  | :unexpected_reply
  | :not_configured

t()

@type t() :: %Huginn.Error{
  __exception__: term(),
  code: integer() | nil,
  details: term(),
  message: String.t(),
  reason: reason()
}

Functions

wrap(error)

@spec wrap(term()) :: t()

Normalizes any failure term produced by the transport or the server into a Huginn.Error. An existing Huginn.Error is returned unchanged.