Skip to main content

rfham_config/
error.rs

1//!
2//! Provides this crate's [`Error`] and [`Result`] types.
3//!
4
5use std::io::Error as IoError;
6use thiserror::Error;
7use toml::{de::Error as ParserError, ser::Error as SerializerError};
8
9// ------------------------------------------------------------------------------------------------
10// Public Types
11// ------------------------------------------------------------------------------------------------
12
13///
14/// The `Error` type for this crate.
15///
16#[derive(Debug, Error)]
17pub enum ConfigError {
18    #[error("An error occured in an I/O operation; error: {0}")]
19    Io(#[from] IoError),
20
21    #[error("Could not determine the location of the configuration directory.")]
22    ConfigDir,
23
24    #[error("An error occured parsing the configuration file; error {0}")]
25    Parser(#[from] ParserError),
26
27    #[error("An error occured serializing the configuration file; error {0}")]
28    Serializer(#[from] SerializerError),
29}
30
31///
32/// A `Result` type that specifically uses this crate's `Error`.
33///
34pub type ConfigResult<T> = std::result::Result<T, ConfigError>;