aoc_toolkit/client/
error.rs1use 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
45 #[error("Cannot determine the system cache directory")]
46 CacheDirectoryUnavailable,
47
48 #[error("Cannot determine the Advent of Code account identity")]
49 AccountIdentityUnavailable,
50
51 #[error("AOC_TOOLKIT_CACHE_DIR must be an absolute path")]
52 InvalidCacheDirectory,
53
54 #[error("The verified account does not match the stored session identity")]
55 AccountIdentityMismatch,
56
57 #[error("Cannot read session configuration from .env")]
58 InvalidSessionConfiguration,
59
60 #[error("AOC_TOOLKIT_CONTACT must contain a valid HTTP header value")]
61 InvalidSyncContact,
62}