1use std::str::Utf8Error;
4
5use http::status::InvalidStatusCode as InvalidStatusCodeError;
6use http::uri::InvalidUri as InvalidUriError;
7use serde_json::Error as JsonError;
8use serde_qs::Error as QueryError;
9
10error_chain!{
11 foreign_links {
12 InvalidStatusCode(InvalidStatusCodeError);
13 InvalidUri(InvalidUriError);
14 Json(JsonError);
15 Query(QueryError);
16 Utf8(Utf8Error);
17 }
18
19 errors {
20 InvalidMemberName(name: String) {
21 description("TODO")
22 display("TODO")
23 }
24
25 MissingField(name: String) {
26 description("A struct was built without a required field.")
27 display(r#"missing required field "{}""#, name)
28 }
29
30 UnsupportedVersion(version: String) {
31 description("The specified version of is not \
32 supported by this implementation.")
33 display(r#"Version "{}" is not yet supported by \
34 this implementation."#, version)
35 }
36 }
37}
38
39impl Error {
40 pub fn missing_field(name: &str) -> Self {
41 Self::from(ErrorKind::MissingField(name.to_owned()))
42 }
43
44 pub fn unsupported_version(version: &str) -> Self {
45 Self::from(ErrorKind::UnsupportedVersion(version.to_owned()))
46 }
47}