Skip to main content

aoc_toolkit/project/
error.rs

1use std::io;
2use std::path::PathBuf;
3
4use thiserror::Error;
5
6#[derive(Debug, Error)]
7pub enum ProjectError {
8    #[error("No aoc.toml found in {start:?} or its ancestors")]
9    NotFound { start: PathBuf },
10
11    #[error("Cannot access directory {path:?}: {source}")]
12    InvalidStartDirectory {
13        path: PathBuf,
14        #[source]
15        source: io::Error,
16    },
17
18    #[error("Path is not a directory: {path:?}")]
19    NotDirectory { path: PathBuf },
20
21    #[error("Failed to read configuration {path:?}: {source}")]
22    ReadConfig {
23        path: PathBuf,
24        #[source]
25        source: io::Error,
26    },
27
28    #[error("Invalid configuration {path:?}: {source}")]
29    ParseConfig {
30        path: PathBuf,
31        #[source]
32        source: toml::de::Error,
33    },
34
35    #[error(
36        "Unsupported configuration schema version: \
37         {found}. Expected {expected}."
38    )]
39    UnsupportedSchemaVersion { found: u32, expected: u32 },
40}