# `BAM.Error`
[🔗](https://github.com/baoulo/bam-elixir/blob/v0.1.0/lib/bam/error.ex#L1)

Failure returned by the public BAM API.

`message` is safe to show to a caller. It names the format, the operation,
and a file offset or line when those are known. It does not include file
bytes. `reason` is an atom defined by this library. Tag names, reference
names, and other file bytes are never turned into atoms.

`category` is the stable class a caller can match on. `context` carries
small identifiers such as `:format`, `:path`, `:offset`, `:virtual_offset`,
and `:line`.

# `category`

```elixir
@type category() ::
  :not_implemented
  | :not_found
  | :io
  | :closed
  | :invalid_argument
  | :invalid_magic
  | :truncated
  | :checksum
  | :resource_limit
  | :corrupt
  | :unsupported
```

# `t`

```elixir
@type t() :: %BAM.Error{
  __exception__: term(),
  category: category(),
  cause: term(),
  context: map(),
  message: String.t(),
  reason: atom()
}
```

# `closed`

```elixir
@spec closed(atom()) :: t()
```

Error for an operation on a handle that was already released.

# `invalid_argument`

```elixir
@spec invalid_argument(atom(), String.t(), map()) :: t()
```

Error for a caller value this function does not accept.

# `new`

```elixir
@spec new(category(), atom(), String.t(), map()) :: t()
```

Builds an error.

`context` is merged with `%{format: format}` when `:format` is passed
separately through the map the caller already built.

# `not_found`

```elixir
@spec not_found(Path.t()) :: t()
```

Error for a path that does not exist.

# `unsupported`

```elixir
@spec unsupported(atom(), String.t(), map()) :: t()
```

Error for a feature this version does not implement.

---

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