# `Arangox.Errno`
[🔗](https://github.com/ArangoDB-Community/arangox/blob/v0.8.0/lib/arangox/errno.ex#L6)

ArangoDB's `errorNum` table as atoms.

Generated from `priv/arangodb/errors-3.12.10.dat`, which is ArangoDB's
`lib/Basics/errors.dat` vendored byte-identically at tag `3.12.10` -- the
server release the driver is pinned to and its integration suite runs
against; `tag/0` below is that pin. Nothing is fetched at build or run
time.

`Arangox.Error` carries the result of `reason/1` in its `:reason` field, so an
application branches on an atom rather than on an integer or on the server's
message:

    case Arangox.get(conn, "/_api/document/things/nope") do
      {:error, %Arangox.Error{reason: :arango_document_not_found}} -> :gone
      {:error, %Arangox.Error{reason: :arango_conflict}} -> :retry
    end

## Naming

The atom is the published constant name with the `ERROR_` prefix stripped and
downcased: `ERROR_ARANGO_CONFLICT` becomes `:arango_conflict`. Constant names
are unique, so the mapping is injective; the short messages are not unique and
are not used. This is a public pattern-matching surface and is stable.

## Unknown codes

A number this table does not contain yields `:unknown`. A server newer
than the pinned tag can introduce codes, and a caller matching on
`%Arangox.Error{reason: reason}` must not crash or receive `nil` when it does.
The status and the raw `errorNum` are preserved on the error either way, so
the number is still available.

348 codes, `0`..`21005`.

# `t`

```elixir
@type t() :: atom()
```

A reason atom from this table, or `:unknown` for a code the pinned
table does not contain.

# `count`

```elixir
@spec count() :: non_neg_integer()
```

How many codes the pinned table contains.

# `error_num`

```elixir
@spec error_num(t()) :: integer() | nil
```

The `errorNum` for a reason atom, or `nil` for one this table does not
contain (including `:unknown`).

    iex> Arangox.Errno.error_num(:arango_conflict)
    1200

    iex> Arangox.Errno.error_num(:unknown)
    nil

# `reason`

```elixir
@spec reason(term()) :: t()
```

The reason atom for an ArangoDB `errorNum`.

Returns `:unknown` for any integer the pinned table does not
contain, and for a non-integer (a server may send anything).

    iex> Arangox.Errno.reason(1202)
    :arango_document_not_found

    iex> Arangox.Errno.reason(9_999_999)
    :unknown

# `reasons`

```elixir
@spec reasons() :: [t()]
```

Every reason atom in the pinned table, sorted. Does not include
`:unknown`.

# `tag`

```elixir
@spec tag() :: binary()
```

The server tag the table is pinned to.

# `unknown`

```elixir
@spec unknown() :: t()
```

The catch-all reason for a code absent from the pinned table.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
