whos_your_daddy_common 0.2.0

Common source code for the Who's Your Daddy projects, like the Enumerator and Presenter.
Documentation
//! Error type definitions for the library.
#![warn(missing_docs)]
use thiserror::Error;

/// Error definitions for database operations.
#[derive(Debug, Error)]
pub enum DbError {
    /// Error for connecting to a database.
    #[error("An error occurred while connecting to the database: {0}")]
    ConnectError(String),

    /// Error for inserting an object into a database.
    #[error("An error occurred while inserting an object into the database: {0}")]
    InsertError(String),

    /// An error occurred while performing a SELECT operation to the database.
    #[error("An error occurred during a SELECT query: {0}")]
    SelectError(String),
}

/// This `Error` type describes the possible errors that could occur in common
/// code within this library.
#[derive(Error, Debug)]
pub enum Error {
    /// Error describing some failure while processing common configuration.
    #[error("An error occurred while gathering common configuration: {0}")]
    ConfigError(String),

    /// This error indicates the API Key for the Congress.gov API could not
    /// be retrieved from the environment.
    #[error(
        "An error occurred while retrieving the congress.gov API key from the environment: {0}"
    )]
    CongressGovApiKeyError(String),

    /// This error indicates an HTTP GET request to Congress.gov failed.
    #[error("An error occurred while performing an HTTP GET request to the congress.gov API: {0}")]
    CongressGovHttpGetError(String),

    /// This error indicates the response body from Congress.gov could not
    /// be read.
    #[error("An error occurred while reading the HTTP response body: {0}")]
    CongressGovResponseError(String),

    /// Error when a name string failed to be split into its constituent parts.
    #[error("Failed to split a name string: {0}")]
    NameSplitError(String),
}