Skip to main content

furmint_runtime/
error.rs

1//! Error handling module
2
3use furmint_resources::ResourceError;
4use thiserror::Error;
5
6/// Alias for `Result<T, RuntimeError>` for convenience
7pub type RuntimeResult<T> = Result<T, RuntimeError>;
8
9/// Possible errors that can occur during runtime
10#[derive(Error, Debug)]
11pub enum RuntimeError {
12    /// IO error
13    #[error(transparent)]
14    Io(#[from] std::io::Error),
15    /// RON parsing error
16    #[error(transparent)]
17    RonParsing(#[from] ron::de::SpannedError),
18    /// TOML parsing error
19    #[error(transparent)]
20    TomlParsing(#[from] toml::de::Error),
21    /// Specs error
22    #[error(transparent)]
23    Specs(#[from] specs::error::Error),
24    /// Plugin setup error
25    #[error("failed to set up plugin `{plugin}`")]
26    PluginSetup {
27        /// Plugin which caused this error
28        plugin: String,
29        /// Error source
30        #[source]
31        source: Box<dyn std::error::Error>,
32    },
33    /// No config path provided to builder
34    #[error("config path cannot be empty")]
35    EmptyConfigPath,
36    /// Any errors related to IO and config file
37    #[error("`{source}`")]
38    ConfigIo {
39        /// Error source
40        #[source]
41        source: std::io::Error,
42    },
43    /// Any errors related to resources/assets
44    #[error(transparent)]
45    ResourceError(#[from] ResourceError),
46}