1use std::fmt;
2
3pub type SurfnetResult<T> = Result<T, SurfnetError>;
4
5#[derive(Debug)]
6pub enum SurfnetError {
7 PortAllocation(String),
9 Startup(String),
11 Runtime(String),
13 Cheatcode(String),
15 Aborted(String),
17}
18
19impl fmt::Display for SurfnetError {
20 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21 match self {
22 SurfnetError::PortAllocation(msg) => write!(f, "port allocation failed: {msg}"),
23 SurfnetError::Startup(msg) => write!(f, "surfnet startup failed: {msg}"),
24 SurfnetError::Runtime(msg) => write!(f, "surfnet runtime error: {msg}"),
25 SurfnetError::Cheatcode(msg) => write!(f, "cheatcode failed: {msg}"),
26 SurfnetError::Aborted(msg) => write!(f, "surfnet aborted: {msg}"),
27 }
28 }
29}
30
31impl std::error::Error for SurfnetError {}