puffin_build/
error.rs

1use std::io;
2use std::path::PathBuf;
3
4use derive_more::From;
5
6use crate::harness::Harness;
7use crate::library::{Builder, Options, Sources};
8use crate::vendor_dir::VendorDir;
9
10pub type Result<T> = std::result::Result<T, Error>;
11
12#[derive(Debug, From)]
13pub enum Error {
14    // -- Vendor Dir
15    VendorDirUnavailable {
16        dir: VendorDir,
17        reason: io::Error,
18    },
19
20    // -- Library
21    SourcesDownloadFailed {
22        sources: Sources,
23        reason: io::Error,
24    },
25
26    LibraryBuilderFailed {
27        builder: Builder,
28        sources: PathBuf,
29        options: Options,
30        reason: io::Error,
31    },
32
33    // -- Harness
34    HarnessFailed {
35        harness: Box<Harness>,
36        reason: io::Error,
37    },
38
39    // -- Other
40    DeserializationFailed {
41        reason: toml::de::Error,
42    },
43}
44
45impl std::fmt::Display for Error {
46    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
47        write!(f, "{self:?}")
48    }
49}
50
51impl std::error::Error for Error {}