1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use std::io;
use std::path::PathBuf;

use derive_more::From;

use crate::harness::Harness;
use crate::library::{Builder, Options, Sources};
use crate::vendor_dir::VendorDir;

pub type Result<T> = std::result::Result<T, Error>;

#[derive(Debug, From)]
pub enum Error {
    // -- Vendor Dir
    VendorDirUnavailable {
        dir: VendorDir,
        reason: io::Error,
    },

    // -- Library
    SourcesDownloadFailed {
        sources: Sources,
        reason: io::Error,
    },

    LibraryBuilderFailed {
        builder: Builder,
        sources: PathBuf,
        options: Options,
        reason: io::Error,
    },

    // -- Harness
    HarnessFailed {
        harness: Box<Harness>,
        reason: io::Error,
    },

    // -- Other
    DeserializationFailed {
        reason: toml::de::Error,
    },
}

impl std::fmt::Display for Error {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{self:?}")
    }
}

impl std::error::Error for Error {}