Skip to main content

twine_ctl/
error.rs

1// Copyright (c) 2026 Jake Swensen
2// SPDX-License-Identifier: MPL-2.0
3//
4// This Source Code Form is subject to the terms of the Mozilla Public
5// License, v. 2.0. If a copy of the MPL was not distributed with this
6// file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
8use thiserror::Error;
9use twine_codec::TwineCodecError;
10
11#[derive(Debug, Error)]
12pub enum TwineCtlError {
13    #[error("Command error: {0}")]
14    CommandError(String),
15
16    #[error(transparent)]
17    IoError(#[from] std::io::Error),
18
19    #[error(transparent)]
20    SerialPortError(#[from] serialport::Error),
21
22    #[error("Serial port read error")]
23    SerialPortReadError,
24
25    #[error("Not enough data returned from a shell command to parse response")]
26    ShellParseError,
27
28    #[error("Timeout waiting for response")]
29    TimeoutError,
30
31    #[error(transparent)]
32    CodecError(#[from] TwineCodecError),
33
34    #[error("Unexpected end of file")]
35    UnexpectedEof,
36}