# `Bolty.Error`

# `t`

```elixir
@type t() :: %Bolty.Error{
  __exception__: term(),
  bolt: %{code: atom() | binary(), message: binary() | nil} | nil,
  code: atom(),
  module: module(),
  packstream: %{bits: any() | nil} | nil
}
```

# `message`

```elixir
@spec message(t()) :: String.t()
```

Return the code for the given error.

### Examples

     iex> {:error, %Bolty.Error{} = error} = do_something()
     iex> Exception.message(error)
     "Unable to perform this action."

# `to_atom`

```elixir
@spec to_atom(String.t() | atom()) :: atom()
```

Gets the corresponding atom based on the error code.

An atom code is already resolved and passes through unchanged; this lets
callers build an error map with a known atom `code` (e.g.
`%{code: :unsupported_message_version, message: ...}`) without it being
collapsed to `:unknown` by the string lookup.

# `wrap`

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

# `wrap`

```elixir
@spec wrap(any(), any(), any()) :: t()
```

---

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