advent_of_utils_cli/error/
input.rs1use std::path::PathBuf;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum InputError {
6 #[error("Failed fetching environment variable ${key}: {reason}")]
7 VarError {
8 key: String,
9 reason: String,
10 #[source]
11 source: Option<std::env::VarError>,
12 },
13
14 #[error("Failed to fetch input for year {year} day {day}: {reason}")]
15 FetchFailed {
16 year: i32,
17 day: u8,
18 reason: String,
19 #[source]
20 source: Option<reqwest::Error>,
21 },
22
23 #[error("Failed to read input file {path}: {reason}")]
24 FileReadError {
25 path: PathBuf,
26 reason: String,
27 #[source]
28 source: Option<std::io::Error>,
29 },
30
31 #[error("Failed to save input to {path}: {reason}")]
32 FileSaveError {
33 path: PathBuf,
34 reason: String,
35 #[source]
36 source: Option<std::io::Error>,
37 },
38
39 #[error("Failed to open editor")]
40 Editor {
41 #[source]
42 source: Option<Box<dyn std::error::Error + Send + Sync>>,
43 },
44
45 #[error(
46 "The test input for day {day} is not set. Run 'aou add-test <YEAR> <DAY>' to set the day"
47 )]
48 NoTestInput { day: u8 },
49
50 #[error("Failed creating a temporary file for setting the test input")]
51 TestInputFailed {
52 #[source]
53 source: Option<Box<dyn std::error::Error + Send + Sync>>,
54 },
55}