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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use crate::report::cobertura;
use failure::Fail;
/// Error states that could be returned from tarpaulin
#[derive(Fail, Debug)]
pub enum RunError {
    /// Error in cargo manifests
    #[fail(display = "Failed to parse Cargo.toml! Error: {}", _0)]
    Manifest(String),
    /// Cargo failed to run
    #[fail(display = "Cargo failed to run! Error: {}", _0)]
    Cargo(String),
    /// Error trying to resolve package configuration in manifest
    #[fail(display = "Failed to resolve package in manifest! Error: {}", _0)]
    Packages(String),
    /// Tests failed to compile
    #[fail(display = "Failed to compile tests! Error: {}", _0)]
    TestCompile(String),
    /// Test failed during run
    #[fail(display = "Failed to run tests: {}", _0)]
    TestRuntime(String),
    #[fail(display = "Test failed during run")]
    TestFailed,
    /// Failed to parse
    #[fail(display = "Error while parsing: {}", _0)]
    Parse(std::io::Error),
    /// Failed to get test coverage
    #[fail(display = "Failed to get test coverage! Error: {}", _0)]
    TestCoverage(String),
    #[fail(display = "Failed to trace! Error: {}", _0)]
    Trace(String),
    #[fail(display = "Failed to report coverage! Error: {}", _0)]
    CovReport(String),
    #[fail(display = "{}", _0)]
    OutFormat(String),
    #[fail(display = "{}", _0)]
    IO(std::io::Error),
    #[fail(display = "Error running test: {}", _0)]
    StateMachine(String),
    //TODO: Better error message!
    #[fail(display = "{}", _0)]
    NixError(nix::Error),
    #[fail(display = "Failed to generate HTML report! Error: {}", _0)]
    Html(String),
    #[fail(display = "Failed to generate XML report! Error: {}", _0)]
    XML(cobertura::Error),
    #[fail(display = "Tarpaulin experienced an internal error")]
    Internal,
}

impl From<std::io::Error> for RunError {
    fn from(e: std::io::Error) -> Self {
        RunError::IO(e)
    }
}

impl From<nix::Error> for RunError {
    fn from(e: nix::Error) -> Self {
        RunError::NixError(e)
    }
}

impl From<cobertura::Error> for RunError {
    fn from(e: cobertura::Error) -> Self {
        RunError::XML(e)
    }
}