diff --git a/src/stanza_error.rs b/src/stanza_error.rs
index 3488b9c..4c09eea 100644
--- a/src/stanza_error.rs
+++ b/src/stanza_error.rs
@@ -215,6 +215,26 @@ pub struct StanzaError {
impl MessagePayload for StanzaError {}
impl PresencePayload for StanzaError {}
+impl StanzaError {
+ /// Create a new `` with the according content.
+ pub fn new(type_: ErrorType, defined_condition: DefinedCondition, lang: L, text: T) -> StanzaError
+ where L: Into,
+ T: Into,
+ {
+ StanzaError {
+ type_,
+ by: None,
+ defined_condition,
+ texts: {
+ let mut map = BTreeMap::new();
+ map.insert(lang.into(), text.into());
+ map
+ },
+ other: None,
+ }
+ }
+}
+
impl TryFrom for StanzaError {
type Err = Error;