Arex.Error (arex v0.1.0)

Copy Markdown View Source

Normalized error constructors used across Arex.

Public helpers return {:error, error_map} tuples where error_map.kind is suitable for pattern matching and the remaining fields preserve debugging context from the originating request.

The goal of this module is stability at the API boundary. Callers should be able to branch on error.kind without parsing raw response payloads, while still having access to the request metadata and any ArcadeDB-specific detail that was available.

In practice this means:

  • transport errors and ArcadeDB errors share one shape
  • kind is the main field for pattern matching in application code
  • request metadata stays attached for observability and debugging
  • helper-level validation failures look the same as remote failures

Most application code will not call these constructors directly, but the module is public so consumers can rely on the documented error shape and the stable kind vocabulary.

Summary

Types

Metadata about the request that produced the error.

t()

Normalized error map returned by Arex APIs.

Functions

Builds a normalized error map from an ArcadeDB failure response.

Returns an error indicating that call options were invalid.

Returns an error indicating that a database name was required but absent.

Builds a normalized ArcadeDB error map from a response body.

Returns an error indicating that an identifier failed validation.

Returns an error indicating that a query or helper matched too many rows.

Returns an error indicating that a requested entity was not found.

Returns an error indicating that scope cannot be used without tenant.

Returns an error indicating that a transaction was required.

Builds an error map from a transport-layer exception.

Returns an error indicating that a type name was required but absent.

Types

request_meta()

@type request_meta() :: %{method: atom() | nil, path: String.t() | nil}

Metadata about the request that produced the error.

t()

@type t() :: %{
  kind: atom(),
  message: String.t(),
  status: integer() | nil,
  arcade_code: String.t() | nil,
  details: any(),
  body: map(),
  request: request_meta()
}

Normalized error map returned by Arex APIs.

kind is the field intended for pattern matching. The remaining fields carry human-readable diagnostics and request context.

Functions

arcadedb(message, status, body, request, arcade_code \\ nil, details \\ nil)

Builds a normalized error map from an ArcadeDB failure response.

bad_opts(message, request, details \\ nil)

Returns an error indicating that call options were invalid.

database_required(request)

Returns an error indicating that a database name was required but absent.

from_body(status, body, request)

Builds a normalized ArcadeDB error map from a response body.

Structured bodies contribute error, detail, and exception fields when they are present. Plain bodies are wrapped into a minimal map so callers still receive a consistent error shape.

invalid_identifier(identifier, request)

Returns an error indicating that an identifier failed validation.

multiple_results(message, request, details \\ nil)

Returns an error indicating that a query or helper matched too many rows.

not_found(message, request, details \\ nil)

Returns an error indicating that a requested entity was not found.

scope_without_tenant(request)

Returns an error indicating that scope cannot be used without tenant.

transaction_required(message, request, details \\ nil)

Returns an error indicating that a transaction was required.

transport(exception, request)

Builds an error map from a transport-layer exception.

type_required(request)

Returns an error indicating that a type name was required but absent.