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
error_chain! {
    types {
        Error, ErrorKind, ResultExt, Result;
    }
    links {
        Server(RavenServerError, RavenServerErrorKind);
    }
    foreign_links {
        Fmt(::std::fmt::Error);
        Io(::std::io::Error);
        Network(::reqwest::Error);
        Parse(::serde_json::error::Error);
    }

    // Define additional `ErrorKind` variants. The syntax here is
    // the same as `quick_error!`, but the `from()` and `cause()`
    // syntax is not supported.
    errors {
        InvalidThemeName(t: String) {
            description("invalid theme name")
            display("invalid theme name: '{}'", t)
        }
    }
}
error_chain! {
    types {
        RavenServerError, RavenServerErrorKind, RavenServerResultExt, RavenServerResult;
    }
    foreign_links {
        Parse(::serde_json::error::Error);
        Network(::reqwest::Error);
    }
    errors {
        PermissionDenied {
            description("inadequate permissions")
            display("not allowed to perform this operation")
        }
        NotLoggedIn {
            description("not logged in")
            display("no login info stored")
        }
        DoesNotExist(t: String) {
            description("the requested resource does not exist")
            display("{} does not exist", t)
        }
        ServerError(code: ::reqwest::StatusCode) {
            description("the server encountered an error")
            display("the server encountered an error. code: {:?}", code)
        }
        TooLarge {
            description("payload was too large")
            display("a payload was sent that was too large")
            //heh
        }
        PreConditionFailed(t: String) {
            description("failed precondition for request")
            display("{} was failed", t)
        }
    }
}