Skip to content

Commit d7c0e24

Browse files
committed
Make AgentError implement std::error::Error
Signed-off-by: Wiktor Kwapisiewicz <[email protected]>
1 parent c815ce2 commit d7c0e24

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/error.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,15 @@ impl From<io::Error> for AgentError {
1919
AgentError::IO(e)
2020
}
2121
}
22+
23+
impl std::fmt::Display for AgentError {
24+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25+
match self {
26+
AgentError::User => write!(f, "Agent: User error"),
27+
AgentError::Proto(proto) => write!(f, "Agent: Protocol error: {}", proto),
28+
AgentError::IO(error) => write!(f, "Agent: I/O error: {}", error),
29+
}
30+
}
31+
}
32+
33+
impl std::error::Error for AgentError {}

0 commit comments

Comments
 (0)