csgo_gsi/
error.rs

1use std::error::Error as StdError;
2use std::fmt;
3
4use fehler::throws;
5
6/// any error caused by this library
7#[derive(Debug)]
8pub enum Error {
9    /// an error encountered when trying to install configuration
10    ConfigInstallError {
11        /// a textual description of the error
12        description: &'static str,
13        /// an upstream cause of the error
14        cause: Option<Box<dyn StdError>>,
15    },
16}
17
18impl fmt::Display for Error {
19    #[throws(fmt::Error)]
20    fn fmt(&self, f: &mut fmt::Formatter) {
21        match self {
22            Error::ConfigInstallError { description, .. } => {
23                write!(f, "CS:GO GSI config install error: {}", description)?;
24            }
25        }
26    }
27}
28
29impl StdError for Error {
30    fn source(&self) -> Option<&(dyn StdError + 'static)> {
31        match self {
32            Error::ConfigInstallError { cause, .. } => cause.as_deref()
33        }
34    }
35}