Skip to content

Commit

Permalink
Make AgentError implement std::error::Error
Browse files Browse the repository at this point in the history
Signed-off-by: Wiktor Kwapisiewicz <[email protected]>
  • Loading branch information
wiktor-k committed Feb 22, 2024
1 parent c815ce2 commit d7c0e24
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,15 @@ impl From<io::Error> for AgentError {
AgentError::IO(e)
}
}

impl std::fmt::Display for AgentError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
AgentError::User => write!(f, "Agent: User error"),
AgentError::Proto(proto) => write!(f, "Agent: Protocol error: {}", proto),
AgentError::IO(error) => write!(f, "Agent: I/O error: {}", error),
}
}
}

impl std::error::Error for AgentError {}

0 comments on commit d7c0e24

Please sign in to comment.