rm stale DomainError, add error docs
This commit is contained in:
parent
ce2ce363b0
commit
d3fab29d38
2 changed files with 23 additions and 25 deletions
46
src/error.rs
46
src/error.rs
|
@ -10,15 +10,21 @@ use trust_dns_proto::error::ProtoError;
|
||||||
use xmpp_parsers::error::Error as ParsersError;
|
use xmpp_parsers::error::Error as ParsersError;
|
||||||
use xmpp_parsers::sasl::DefinedCondition as SaslDefinedCondition;
|
use xmpp_parsers::sasl::DefinedCondition as SaslDefinedCondition;
|
||||||
|
|
||||||
|
/// Top-level error type
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
|
/// I/O error
|
||||||
Io(IoError),
|
Io(IoError),
|
||||||
|
/// Error resolving DNS and establishing a connection
|
||||||
Connection(ConnecterError),
|
Connection(ConnecterError),
|
||||||
/// DNS label conversion error, no details available from module
|
/// DNS label conversion error, no details available from module
|
||||||
/// `idna`
|
/// `idna`
|
||||||
Idna,
|
Idna,
|
||||||
|
/// Protocol-level error
|
||||||
Protocol(ProtocolError),
|
Protocol(ProtocolError),
|
||||||
|
/// Authentication error
|
||||||
Auth(AuthError),
|
Auth(AuthError),
|
||||||
|
/// TLS error
|
||||||
Tls(TlsError),
|
Tls(TlsError),
|
||||||
/// Shoud never happen
|
/// Shoud never happen
|
||||||
InvalidState,
|
InvalidState,
|
||||||
|
@ -62,57 +68,49 @@ impl fmt::Display for ParseError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// XMPP protocol-level error
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum ProtocolError {
|
pub enum ProtocolError {
|
||||||
|
/// XML parser error
|
||||||
Parser(ParserError),
|
Parser(ParserError),
|
||||||
|
/// Error with expected stanza schema
|
||||||
#[error(non_std)]
|
#[error(non_std)]
|
||||||
Parsers(ParsersError),
|
Parsers(ParsersError),
|
||||||
|
/// No TLS available
|
||||||
NoTls,
|
NoTls,
|
||||||
|
/// Invalid response to resource binding
|
||||||
InvalidBindResponse,
|
InvalidBindResponse,
|
||||||
|
/// No xmlns attribute in <stream:stream>
|
||||||
NoStreamNamespace,
|
NoStreamNamespace,
|
||||||
|
/// No id attribute in <stream:stream>
|
||||||
NoStreamId,
|
NoStreamId,
|
||||||
|
/// Encountered an unexpected XML token
|
||||||
InvalidToken,
|
InvalidToken,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Authentication error
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum AuthError {
|
pub enum AuthError {
|
||||||
/// No SASL mechanism available
|
/// No matching SASL mechanism available
|
||||||
NoMechanism,
|
NoMechanism,
|
||||||
|
/// Local SASL implementation error
|
||||||
#[error(no_from, non_std, msg_embedded)]
|
#[error(no_from, non_std, msg_embedded)]
|
||||||
Sasl(String),
|
Sasl(String),
|
||||||
|
/// Failure from server
|
||||||
#[error(non_std)]
|
#[error(non_std)]
|
||||||
Fail(SaslDefinedCondition),
|
Fail(SaslDefinedCondition),
|
||||||
|
/// Component authentication failure
|
||||||
#[error(no_from)]
|
#[error(no_from)]
|
||||||
ComponentFail,
|
ComponentFail,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Error establishing connection
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum ConnecterError {
|
pub enum ConnecterError {
|
||||||
NoSrv,
|
/// All attempts failed, no error available
|
||||||
AllFailed,
|
AllFailed,
|
||||||
/// DNS name error
|
/// DNS protocol error
|
||||||
Domain(DomainError),
|
|
||||||
/// DNS resolution error
|
|
||||||
Dns(ProtoError),
|
Dns(ProtoError),
|
||||||
/// DNS resolution error
|
/// DNS resolution error
|
||||||
Resolve(ResolveError),
|
Resolve(ResolveError),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// DNS name error wrapper type
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct DomainError(pub String);
|
|
||||||
|
|
||||||
impl StdError for DomainError {
|
|
||||||
fn description(&self) -> &str {
|
|
||||||
&self.0
|
|
||||||
}
|
|
||||||
fn cause(&self) -> Option<&StdError> {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for DomainError {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
write!(f, "{}", self.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// #![deny(unsafe_code, unused, missing_docs)]
|
#![deny(unsafe_code, unused, missing_docs)]
|
||||||
|
|
||||||
//! XMPP implemeentation with asynchronous I/O using Tokio.
|
//! XMPP implemeentation with asynchronous I/O using Tokio.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue