aoc-toolkit 0.1.0-alpha.3

A toolkit for solving Advent of Code problems
Documentation
use reqwest::StatusCode;
use std::io;
use std::path::PathBuf;
use thiserror::Error;

#[derive(Debug, Error)]
pub enum ClientError {
    #[error("No Advent of Code session configured")]
    MissingSession,

    #[error("Invalid Advent of Code session token")]
    InvalidSession,

    #[error("Advent of Code rejected the session")]
    Unauthorized,

    #[error("The requested puzzle input is unavailable")]
    InputUnavailable,

    #[error("Advent of Code request rate limit exceeded")]
    RateLimited,

    #[error("Unexpected HTTP status: {0}")]
    UnexpectedStatus(StatusCode),

    #[error("Unexpected response from Advent of Code")]
    InvalidResponse,

    #[error("Advent of Code HTTP request failed")]
    Http(#[from] reqwest::Error),

    #[error("Filesystem operation failed for {path:?}: {source}")]
    Io {
        path: PathBuf,
        #[source]
        source: io::Error,
    },

    #[error("Cannot access the system credential store")]
    CredentialStore,

    #[error("Cannot start browser login. Try `aoc auth login --manual`")]
    BrowserUnavailable,

    #[error("Cannot determine the system cache directory")]
    CacheDirectoryUnavailable,

    #[error("Cannot determine the Advent of Code account identity")]
    AccountIdentityUnavailable,

    #[error("AOC_TOOLKIT_CACHE_DIR must be an absolute path")]
    InvalidCacheDirectory,

    #[error("The verified account does not match the stored session identity")]
    AccountIdentityMismatch,

    #[error("Cannot read session configuration from .env")]
    InvalidSessionConfiguration,
}