Skip to main content

aoc_toolkit/scaffold/
error.rs

1use std::io;
2use std::path::PathBuf;
3
4use thiserror::Error;
5
6#[derive(Debug, Error)]
7pub enum ScaffoldError {
8    #[error("Invalid relative path: {0:?}")]
9    InvalidPath(PathBuf),
10
11    #[error("File already exists: {0:?}")]
12    FileExists(PathBuf),
13
14    #[error("Conflicting planned path: {0:?}")]
15    PathConflict(PathBuf),
16
17    #[error("Expected a directory: {0:?}")]
18    NotDirectory(PathBuf),
19
20    #[error("Symbolic links are not supported: {0:?}")]
21    SymbolicLink(PathBuf),
22
23    #[error("Filesystem operation failed for {path:?}: {source}")]
24    Io {
25        path: PathBuf,
26        #[source]
27        source: io::Error,
28    },
29
30    #[error(transparent)]
31    Template(#[from] minijinja::Error),
32
33    #[error("File does not exist: {0:?}")]
34    FileNotFound(PathBuf),
35
36    #[error("Expected a regular file: {0:?}")]
37    NotFile(PathBuf),
38
39    #[error("File changed since the scaffold plan was created: {0:?}")]
40    FileChanged(PathBuf),
41
42    #[error("Unsupported or modified managed file: {0:?}")]
43    InvalidManagedFile(PathBuf),
44
45    #[error("Invalid year directory prefix: {0:?}")]
46    InvalidYearPrefix(String),
47
48    #[error("Day {day} of year {year} is already registered")]
49    DayAlreadyRegistered { year: usize, day: usize },
50}