use std::{fmt, io}; use fmt::{Display, Formatter, Result}; use zip::result::ZipError; /// Represents all possible errors that can occur in the DML launcher. /// /// This enum centralizes error handling for the entire application, /// wrapping various underlying error types from I/O, HTTP requests, /// JSON parsing, ZIP extraction, configuration issues, and runtime errors. #[allow(dead_code)] #[derive(Debug)] pub enum McError { Io(io::Error), Http(reqwest::Error), Json(serde_json::Error), Zip(ZipError), Config(String), ShaMismatch(String), Process(String), Runtime(String), } impl Display for McError { /// Formats the error for user-friendly display. /// /// Currently, it uses the `Debug` format for simplicity. fn fmt(&self, f: &mut Formatter<'_>) -> Result { write!(f, "{:?}", self) } } impl From for McError { fn from(e: io::Error) -> Self { Self::Io(e) } } impl From for McError { fn from(e: reqwest::Error) -> Self { Self::Http(e) } } impl From for McError { fn from(e: serde_json::Error) -> Self { Self::Json(e) } } impl From for McError { fn from(e: ZipError) -> Self { Self::Zip(e) } }