2017-02-21 16:38:29 +00:00
|
|
|
//! Provides an `Error` for use in this crate.
|
|
|
|
|
2017-05-02 16:21:03 +00:00
|
|
|
use std::fmt::Error as FormatError;
|
|
|
|
|
2017-02-18 21:16:20 +00:00
|
|
|
use std::io;
|
|
|
|
|
|
|
|
use std::net::TcpStream;
|
2017-12-28 04:31:36 +00:00
|
|
|
use std::str::Utf8Error;
|
2017-02-18 21:16:20 +00:00
|
|
|
|
|
|
|
use openssl::ssl::HandshakeError;
|
|
|
|
use openssl::error::ErrorStack;
|
|
|
|
|
2017-12-28 03:06:40 +00:00
|
|
|
use quick_xml::errors::Error as XmlError;
|
2017-02-18 21:16:20 +00:00
|
|
|
|
2017-02-21 16:14:54 +00:00
|
|
|
use minidom::Error as MinidomError;
|
2017-02-19 20:00:59 +00:00
|
|
|
|
2017-04-30 01:04:11 +00:00
|
|
|
use base64::DecodeError;
|
2017-02-24 16:16:51 +00:00
|
|
|
|
2017-03-07 17:19:09 +00:00
|
|
|
use components::sasl_error::SaslError;
|
|
|
|
|
2017-02-21 16:38:29 +00:00
|
|
|
/// An error which wraps a bunch of errors from different crates and the stdlib.
|
2017-02-18 21:16:20 +00:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum Error {
|
|
|
|
XmlError(XmlError),
|
|
|
|
IoError(io::Error),
|
|
|
|
HandshakeError(HandshakeError<TcpStream>),
|
|
|
|
OpenSslErrorStack(ErrorStack),
|
2017-02-19 20:00:59 +00:00
|
|
|
MinidomError(MinidomError),
|
2017-04-30 01:04:11 +00:00
|
|
|
Base64Error(DecodeError),
|
2017-02-24 16:20:00 +00:00
|
|
|
SaslError(Option<String>),
|
2017-03-07 17:19:09 +00:00
|
|
|
XmppSaslError(SaslError),
|
2017-05-02 16:21:03 +00:00
|
|
|
FormatError(FormatError),
|
2017-12-28 04:31:36 +00:00
|
|
|
Utf8Error(Utf8Error),
|
2017-02-18 21:16:20 +00:00
|
|
|
StreamError,
|
2017-02-19 17:08:35 +00:00
|
|
|
EndOfDocument,
|
2017-02-18 21:16:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<XmlError> for Error {
|
|
|
|
fn from(err: XmlError) -> Error {
|
|
|
|
Error::XmlError(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<io::Error> for Error {
|
|
|
|
fn from(err: io::Error) -> Error {
|
|
|
|
Error::IoError(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<HandshakeError<TcpStream>> for Error {
|
|
|
|
fn from(err: HandshakeError<TcpStream>) -> Error {
|
|
|
|
Error::HandshakeError(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<ErrorStack> for Error {
|
|
|
|
fn from(err: ErrorStack) -> Error {
|
|
|
|
Error::OpenSslErrorStack(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-19 20:00:59 +00:00
|
|
|
impl From<MinidomError> for Error {
|
|
|
|
fn from(err: MinidomError) -> Error {
|
|
|
|
Error::MinidomError(err)
|
|
|
|
}
|
|
|
|
}
|
2017-02-24 16:16:51 +00:00
|
|
|
|
2017-04-30 01:04:11 +00:00
|
|
|
impl From<DecodeError> for Error {
|
|
|
|
fn from(err: DecodeError) -> Error {
|
2017-02-24 16:16:51 +00:00
|
|
|
Error::Base64Error(err)
|
|
|
|
}
|
|
|
|
}
|
2017-05-02 16:21:03 +00:00
|
|
|
|
|
|
|
impl From<FormatError> for Error {
|
|
|
|
fn from(err: FormatError) -> Error {
|
|
|
|
Error::FormatError(err)
|
|
|
|
}
|
|
|
|
}
|
2017-12-28 04:31:36 +00:00
|
|
|
|
|
|
|
impl From<Utf8Error> for Error {
|
|
|
|
fn from(err: Utf8Error) -> Error {
|
|
|
|
Error::Utf8Error(err)
|
|
|
|
}
|
|
|
|
}
|