omnisor/
error.rs

1use std::io;
2
3// use thiserror::Error;
4use tokio::sync::mpsc;
5
6/// This is the `thiserror` error for all crate errors.
7///
8/// Most ssh related error is wrapped in the `SshError` variant,
9/// giving access to the underlying [`russh::Error`] type.
10#[derive(thiserror::Error, Debug)]
11#[non_exhaustive]
12pub enum Error {
13    #[error("Keyboard-interactive authentication failed")]
14    KeyboardInteractiveAuthFailed,
15    #[error("No keyboard-interactive response for prompt: {0}")]
16    KeyboardInteractiveNoResponseForPrompt(String),
17    #[error("Key authentication failed")]
18    KeyAuthFailed,
19    #[error("Unable to load key, bad format or passphrase: {0}")]
20    KeyInvalid(russh::keys::Error),
21    #[error("Password authentication failed")]
22    PasswordWrong,
23    #[error("Invalid address was provided: {0}")]
24    AddressInvalid(io::Error),
25    #[error("The executed command didn't send an exit code")]
26    CommandDidntExit,
27    #[error("Server check failed")]
28    ServerCheckFailed,
29    #[error("Ssh error occured: {0}")]
30    SshError(#[from] russh::Error),
31    #[error("Send error")]
32    SendError(#[from] russh::SendError),
33    #[error("Agent auth error")]
34    AgentAuthError(#[from] russh::AgentAuthError),
35    #[error("Failed to connect to SSH agent")]
36    AgentConnectionFailed,
37    #[error("Failed to request identities from SSH agent")]
38    AgentRequestIdentitiesFailed,
39    #[error("SSH agent has no identities")]
40    AgentNoIdentities,
41    #[error("SSH agent authentication failed")]
42    AgentAuthenticationFailed,
43    #[error("SFTP error occured: {0}")]
44    SftpError(#[from] russh_sftp::client::error::Error),
45    #[error("I/O error")]
46    IoError(#[from] io::Error),
47    #[error("Channel send error")]
48    ChannelSendError(#[from] mpsc::error::SendError<Vec<u8>>),
49    #[error("Invalid prompt pattern: {0}")]
50    InvalidPromptPattern(String),
51    #[error("Device command timed out waiting for prompt")]
52    DeviceTimeout,
53    #[error("Device session was closed unexpectedly")]
54    DeviceSessionClosed,
55    #[error("Invalid address: {0}")]
56    InvalidAddress(String),
57    #[error("EnableModePasswordFailed")]
58    EnableModePasswordFailed,
59    #[error("EnableModeCommandFailed")]
60    EnableModeCommandFailed,
61    #[error("EnableCommandDidntExit")]
62    EnableCommandDidntExit,
63    #[error("ConfigCommandDidntExit")]
64    ConfigCommandDidntExit,
65}