proxy.rs

 1use thiserror::Error;
 2
 3#[derive(Error, Debug)]
 4pub enum ProxyLaunchError {
 5    #[error("Attempted reconnect, but server not running.")]
 6    ServerNotRunning,
 7}
 8
 9impl ProxyLaunchError {
10    pub const fn to_exit_code(&self) -> i32 {
11        match self {
12            // We're using 90 as the exit code, because 0-78 are often taken
13            // by shells and other conventions and >128 also has certain meanings
14            // in certain contexts.
15            Self::ServerNotRunning => 90,
16        }
17    }
18
19    pub const fn from_exit_code(exit_code: i32) -> Option<Self> {
20        match exit_code {
21            90 => Some(Self::ServerNotRunning),
22            _ => None,
23        }
24    }
25}