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
use git2::Error as GitError;
use log::SetLoggerError;
use reqwest::{StatusCode, Error as ReqwestError};
use serde_json::Error as SerdeError;
use std::io::Error as IoError;
use ws::Error as WsError;

error_chain! {
    foreign_links {
        Git(GitError);
        Io(IoError);
        Json(SerdeError);
        Reqwest(ReqwestError);
        SetLogger(SetLoggerError);
        Ws(WsError);
    }

    errors {
        StageNotFound(stage: String) {
            description("Could not find stage")
            display("Could not find stage: '{}'", stage)
        }
        Unauthorized {
            description("Unauthorized")
            display("Unauthorized")
        }
        Http(status: StatusCode, body: String) {
            description("Error in HTTP request")
            display("Status: {}, Response: {}", status, body)
        }
        InvalidSherpaStage(stage: String) {
            description("Invalid Sherpa stage.")
            display("Invalid Sherpa stage: '{}'", stage)
        }
    }
}