aboutsummaryrefslogtreecommitdiffstats
path: root/stanza/src/stanza_error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'stanza/src/stanza_error.rs')
-rw-r--r--stanza/src/stanza_error.rs31
1 files changed, 27 insertions, 4 deletions
diff --git a/stanza/src/stanza_error.rs b/stanza/src/stanza_error.rs
index 99c1f15..6aec98c 100644
--- a/stanza/src/stanza_error.rs
+++ b/stanza/src/stanza_error.rs
@@ -4,32 +4,55 @@ use peanuts::{
element::{FromElement, IntoElement},
Element, XML_NS,
};
+use thiserror::Error;
pub const XMLNS: &str = "urn:ietf:params:xml:ns:xmpp-stanzas";
-#[derive(Clone, Debug)]
+#[derive(Error, Clone, Debug)]
pub enum Error {
+ #[error("bad request")]
BadRequest,
+ #[error("conflict")]
Conflict,
+ #[error("feature not implemented")]
FeatureNotImplemented,
+ #[error("forbidden")]
Forbidden,
+ #[error("gone: {0:?}")]
Gone(Option<String>),
+ #[error("internal server error")]
InternalServerError,
+ #[error("item not found")]
ItemNotFound,
- JidMalformed,
+ #[error("JID malformed")]
+ JIDMalformed,
+ #[error("not acceptable")]
NotAcceptable,
+ #[error("not allowed")]
NotAllowed,
+ #[error("not authorized")]
NotAuthorized,
+ #[error("policy violation")]
PolicyViolation,
+ #[error("recipient unavailable")]
RecipientUnavailable,
+ #[error("redirect: {0:?}")]
Redirect(Option<String>),
+ #[error("registration required")]
RegistrationRequired,
+ #[error("remote server not found")]
RemoteServerNotFound,
+ #[error("remote server timeout")]
RemoteServerTimeout,
+ #[error("resource constraint")]
ResourceConstraint,
+ #[error("service unavailable")]
ServiceUnavailable,
+ #[error("subscription required")]
SubscriptionRequired,
+ #[error("undefined condition")]
UndefinedCondition,
+ #[error("unexpected request")]
UnexpectedRequest,
}
@@ -44,7 +67,7 @@ impl FromElement for Error {
(Some(XMLNS), "gone") => return Ok(Error::Gone(element.pop_value_opt()?)),
(Some(XMLNS), "internal-server-error") => error = Error::InternalServerError,
(Some(XMLNS), "item-not-found") => error = Error::ItemNotFound,
- (Some(XMLNS), "jid-malformed") => error = Error::JidMalformed,
+ (Some(XMLNS), "jid-malformed") => error = Error::JIDMalformed,
(Some(XMLNS), "not-acceptable") => error = Error::NotAcceptable,
(Some(XMLNS), "not-allowed") => error = Error::NotAllowed,
(Some(XMLNS), "not-authorized") => error = Error::NotAuthorized,
@@ -78,7 +101,7 @@ impl IntoElement for Error {
Error::Gone(r) => Element::builder("gone", Some(XMLNS)).push_text_opt(r.clone()),
Error::InternalServerError => Element::builder("internal-server-error", Some(XMLNS)),
Error::ItemNotFound => Element::builder("item-not-found", Some(XMLNS)),
- Error::JidMalformed => Element::builder("jid-malformed", Some(XMLNS)),
+ Error::JIDMalformed => Element::builder("jid-malformed", Some(XMLNS)),
Error::NotAcceptable => Element::builder("not-acceptable", Some(XMLNS)),
Error::NotAllowed => Element::builder("not-allowed", Some(XMLNS)),
Error::NotAuthorized => Element::builder("not-authorized", Some(XMLNS)),