Skip to main content

aoc_toolkit/client/
error.rs

1use reqwest::StatusCode;
2use std::io;
3use std::path::PathBuf;
4use thiserror::Error;
5
6#[derive(Debug, Error)]
7pub enum ClientError {
8    #[error("No Advent of Code session configured")]
9    MissingSession,
10
11    #[error("Invalid Advent of Code session token")]
12    InvalidSession,
13
14    #[error("Advent of Code rejected the session")]
15    Unauthorized,
16
17    #[error("The requested puzzle input is unavailable")]
18    InputUnavailable,
19
20    #[error("Advent of Code request rate limit exceeded")]
21    RateLimited,
22
23    #[error("Unexpected HTTP status: {0}")]
24    UnexpectedStatus(StatusCode),
25
26    #[error("Unexpected response from Advent of Code")]
27    InvalidResponse,
28
29    #[error("Advent of Code HTTP request failed")]
30    Http(#[from] reqwest::Error),
31
32    #[error("Filesystem operation failed for {path:?}: {source}")]
33    Io {
34        path: PathBuf,
35        #[source]
36        source: io::Error,
37    },
38
39    #[error("Cannot access the system credential store")]
40    CredentialStore,
41
42    #[error("Cannot start browser login. Try `aoc auth login --manual`")]
43    BrowserUnavailable,
44}