cobble_core/error/
launch_error.rs

1/// Result with [`LaunchError`](LaunchError) as the error type.
2pub type LaunchResult<T> = Result<T, LaunchError>;
3
4/// An error that occurs during installation of minecraft.
5#[derive(Debug, thiserror::Error)]
6#[non_exhaustive]
7pub enum LaunchError {
8    /// IO error
9    #[error("{0}")]
10    Io(std::io::Error),
11    /// Failed to send stop signal to game process
12    #[cfg_attr(doc_cfg, doc(cfg(unix)))]
13    #[cfg(unix)]
14    #[error("{0}")]
15    Ipc(ipc_channel::ipc::IpcError),
16    /// Failed to fork game process
17    #[cfg_attr(doc_cfg, doc(cfg(unix)))]
18    #[cfg(unix)]
19    #[error("Failed to fork game process")]
20    ProcessForking,
21    /// Failed to wait for the game process to exit.
22    /// When this error occurs, there may be a zombie process left.
23    #[cfg_attr(doc_cfg, doc(cfg(unix)))]
24    #[cfg(unix)]
25    #[error("Failed to wait for the game process to exit. There may be a zombie process left.")]
26    WaitPid,
27}
28
29impl From<std::io::Error> for LaunchError {
30    fn from(err: std::io::Error) -> Self {
31        Self::Io(err)
32    }
33}
34
35#[cfg(unix)]
36impl From<ipc_channel::ipc::IpcError> for LaunchError {
37    fn from(err: ipc_channel::ipc::IpcError) -> Self {
38        Self::Ipc(err)
39    }
40}