# `ADS.ReturnCode`
[🔗](https://github.com/tallakt/yaads/blob/v0.1.0/lib/ads/return_code.ex#L1)

The return codes of ADS, which a device or a router answers with when something goes wrong.

Each has a name, Beckhoff's identifier in snake case with its words spelled out, and the prefix
of its group kept: `ERR_TARGETPORTNOTFOUND` is `:target_port_not_found`,
`ROUTERERR_MAILBOXFULL` is `:router_mailbox_full`, `ADSERR_DEVICE_SYMBOLNOTFOUND` is
`:device_symbol_not_found`, `ADSERR_CLIENT_SYNCTIMEOUT` is `:client_sync_timeout` and
`RTERR_INTERNAL` is `:rt_internal`.

| Codes | Group |
|---|---|
| `0x0` to `0x1E` | the AMS router and transport |
| `0x500` to `0x50D` | the router's resources |
| `0x700` to `0x739` | the device: `:device_...` |
| `0x740` to `0x756` | Beckhoff's client libraries: `:client_...` |
| `0x1000` to `0x101A` | the real-time system: `:rt_...` |

Windows and .NET show them as HRESULTs, `0x9811_0000` plus the code, which `name/1` takes too.

    iex> ADS.ReturnCode.name(0x710)
    :device_symbol_not_found
    iex> ADS.ReturnCode.name(0x9811_0006)
    :target_port_not_found
    iex> ADS.ReturnCode.name(0x799)
    1945
    iex> ADS.ReturnCode.code(:device_symbol_version_invalid)
    0x711

# `name`

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

The name of a return code, an atom; see the table of `ADS.ReturnCode`.

# `all`

```elixir
@spec all() :: %{required(non_neg_integer()) =&gt; name()}
```

All return codes and their names.

# `code`

```elixir
@spec code(name() | non_neg_integer()) :: non_neg_integer()
```

The number of a return code, given by name or number.

# `name`

```elixir
@spec name(non_neg_integer()) :: name() | non_neg_integer()
```

The name of a return code, or the code itself if it has none.

---

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