ssh_agent_lib/
error.rs

1//! SSH agent errors.
2
3use std::io;
4
5use thiserror::Error;
6
7use crate::proto::ProtoError;
8
9/// SSH agent error.
10#[derive(Debug, Error)]
11pub enum AgentError {
12    /// Protocol error.
13    #[error("Agent: Protocol error: {0}")]
14    Proto(#[from] ProtoError),
15
16    /// Input/output error.
17    #[error("Agent: I/O error: {0}")]
18    IO(#[from] io::Error),
19
20    /// Other unspecified error.
21    #[error("Other error: {0:#}")]
22    Other(#[from] Box<dyn std::error::Error + Send + Sync + 'static>),
23
24    /// Generic agent extension failure
25    #[error("Generic agent extension failure")]
26    ExtensionFailure,
27
28    /// Generic agent failure
29    #[error("Generic agent failure")]
30    Failure,
31}
32
33impl AgentError {
34    /// Construct an `AgentError` from other error type.
35    pub fn other(error: impl std::error::Error + Send + Sync + 'static) -> Self {
36        Self::Other(Box::new(error))
37    }
38}