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