furmint-runtime 0.1.0

Main package of furmint game engine providing higher level API
Documentation
//! Error handling module

use furmint_resources::ResourceError;
use thiserror::Error;

/// Alias for `Result<T, RuntimeError>` for convenience
pub type RuntimeResult<T> = Result<T, RuntimeError>;

/// Possible errors that can occur during runtime
#[derive(Error, Debug)]
pub enum RuntimeError {
    /// IO error
    #[error(transparent)]
    Io(#[from] std::io::Error),
    /// RON parsing error
    #[error(transparent)]
    RonParsing(#[from] ron::de::SpannedError),
    /// TOML parsing error
    #[error(transparent)]
    TomlParsing(#[from] toml::de::Error),
    /// Specs error
    #[error(transparent)]
    Specs(#[from] specs::error::Error),
    /// Plugin setup error
    #[error("failed to set up plugin `{plugin}`")]
    PluginSetup {
        /// Plugin which caused this error
        plugin: String,
        /// Error source
        #[source]
        source: Box<dyn std::error::Error>,
    },
    /// No config path provided to builder
    #[error("config path cannot be empty")]
    EmptyConfigPath,
    /// Any errors related to IO and config file
    #[error("`{source}`")]
    ConfigIo {
        /// Error source
        #[source]
        source: std::io::Error,
    },
    /// Any errors related to resources/assets
    #[error(transparent)]
    ResourceError(#[from] ResourceError),
}