use std::num;
use std::io;
use std::net::AddrParseError;
use super::decode_error;
use super::lexer_error;
use serialize::txt::Token;
error_chain! {
types {
Error, ErrorKind, ChainErr, Result;
}
links {
decode_error::Error, decode_error::ErrorKind, Decode;
lexer_error::Error, lexer_error::ErrorKind, Lexer;
}
foreign_links {
io::Error, Io, "io error";
num::ParseIntError, ParseInt, "parse int error";
AddrParseError, AddrParse, "address parse error";
}
errors {
Message(msg: &'static str) {
description(msg)
display("{}", msg)
}
UnexpectedToken(token: Token) {
description("unrecognized token in stream")
display("unrecognized token in stream: {:?}", token)
}
MissingToken(string: String) {
description("token is missing")
display("token is missing: {}", string)
}
CharToIntError(ch: char) {
description("invalid numerical character")
display("invalid numerical character: {}", ch)
}
ParseTimeError(string: String) {
description("invalid time string")
display("invalid time string: {}", string)
}
}
}
impl From<Error> for io::Error {
fn from(e: Error) -> Self {
io::Error::new(io::ErrorKind::Other, format!("DNS ParseError: {}", e))
}
}