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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
use std::io;
use std::num;
use std::time;
use std::path::PathBuf;
use toml;
use serde_json;
use glob;

quick_error! {
    #[derive(Debug)]
    pub enum CargoDebError {
        Io(err: io::Error) {
            from()
            description(err.description())
            display("I/O error: {}", err)
            cause(err)
        }
        IoFile(msg: &'static str, err: io::Error, file: PathBuf) {
            description(msg)
            display("{}: {}", msg, file.display())
            cause(err)
        }
        CommandFailed(err: io::Error, cmd: &'static str) {
            description(err.description())
            display("Command {} failed to launch", cmd)
            cause(err)
        }
        CommandError(msg: &'static str, arg: String, reason: Vec<u8>) {
            description(msg)
            display("{} ({}): {}", msg, arg, String::from_utf8_lossy(reason))
        }
        Str(msg: &'static str) {
            from()
            description(msg)
        }
        NumParse(msg: &'static str, err: num::ParseIntError) {
            description(msg)
            cause(err)
        }
        InstallFailed {
            description("dpkg install failed")
        }
        BuildFailed {
            description("build failed")
        }
        StripFailed(name: PathBuf, reason: String) {
            description(reason)
            display("unable to strip binary '{}': {}", name.display(), reason)
        }
        SystemTime(err: time::SystemTimeError) {
            from()
            description("unable to get system time")
            cause(err)
        }
        ParseTOML(err: toml::de::Error) {
            from()
            description(err.description())
            display("unable to parse Cargo.toml")
            cause(err)
        }
        ParseJSON(err: serde_json::Error) {
            from()
            description(err.description())
            display("unable to parse `cargo metadata` output")
            cause(err)
        }
        PackageNotFound(path: String, reason: Vec<u8>) {
            description("unable to find package for the library")
            display("path '{}' does not belong to a package: {}", path, String::from_utf8_lossy(reason))
        }
        VariantNotFound(variant: String) {
            description("unable to find the passed metadata variant")
            display("[package.metadata.deb.variants.{}] not found in Cargo.toml", variant)
        }
        GlobPatternError(err: glob::PatternError) {
            from()
            description(err.description())
            display("unable to parse glob pattern")
            cause(err)
        }
        AssetGlobError(err: glob::GlobError) {
            from()
            description(err.description())
            display("unable to iterate asset glob result")
            cause(err)
        }
    }
}

pub type CDResult<T> = Result<T, CargoDebError>;