<!-- Source: https://medius.k4tech.net/library/types/errors -->
# Errors

_The Error enum and the Result alias_

Every fallible call returns `Result<T>`, the crate's alias for `core::result::Result<T, Error>`.

`Error` is [`#[non_exhaustive]`](https://doc.rust-lang.org/reference/attributes/type_system.html), so any `match` needs a wildcard arm.

| Variant | Meaning |
| --- | --- |
| `Io(std::io::Error)` | An underlying serial or OS error. |
| `NotFound` | No device matched the expected VID/PID. |
| `NoReply` | The box never answered the version query during the [handshake](/library/connection.md): wrong port or baud, or not a Medius box. |
| `BadProtoVer { got }` | The box answered, but its `proto_ver` wasn't `3`; `got` carries the reported value. See the [handshake](/library/connection.md). |
| `QueryTimeout` | A [`query`](/library/requests.md) hit its deadline with no [`RESP`](/native/commands/requests.md#resp) back. |
| `Disconnected` | The device disconnected. |
| `FrameTooLong` | A payload was over the [512-byte](/native/frame.md#layout) frame limit. |
| `FlashTool(String)` | The flash tool failed. |

> **Warning**
>
> `FlashTool(String)` only exists with the [`flash`](/library/features/flash.md) feature. On a default build the variant isn't in the enum, so a `match` arm naming it won't compile. Gate such arms behind `#[cfg(feature = "flash")]` or lean on the wildcard.
