ssdp/
error.rs

1use std::io;
2use std::net;
3use hyper;
4
5/// Enumerates all errors that can occur when dealing with an SSDP message.
6error_chain! {
7
8    types {
9        SSDPError, SSDPErrorKind, SSDPResultExt, SSDPResult;
10    }
11    
12    errors {
13        /// Message is not valid HTTP.
14        ///
15        /// Message is supplied as a list of bytes.
16        InvalidHttp(message:Vec<u8>) {
17            description("invalid HTTP")
18            display("invalid HTTP message: '{:?}'", message)
19        }
20        /// Message did not specify HTTP/1.1 as version.
21        InvalidHttpVersion { }
22        /// Message consists of an error code.
23        ///
24        /// Error code is supplied.
25        ResponseCode(code:u16) {
26            description("HTTP Error response")
27            display("HTTP Error response: {}", code)
28        }
29        /// Method supplied is not a valid SSDP method.
30        ///
31        /// Method received is supplied.
32        InvalidMethod(method:String) {
33            description("invalid SSDP method")
34            display("invalid SSDP method: '{}'", method)
35        }
36        /// Uri supplied is not a valid SSDP uri.
37        ///
38        /// URI received is supplied.
39        InvalidUri(uri:String) {
40            description("invalid URI")
41            display("invalid URI: '{}'", uri)
42        }
43        /// Header is missing from the message.
44        ///
45        /// Expected header is supplied.
46        MissingHeader(header:&'static str) {
47            description("missing header")
48            display("missing header: '{}'", header)
49        }
50        /// Header has an invalid value.
51        ///
52        /// Header name with error message are supplied.
53        InvalidHeader(header:&'static str, msg:&'static str) {
54            description("invalid header")
55            display("invalid header: '{}': {}", header, msg)
56        }
57    }
58
59    foreign_links {
60        Io(io::Error);
61        AddrParseError(net::AddrParseError);
62        Hyper(hyper::Error);
63        HyperParseError(hyper::error::ParseError);
64    }
65}