| author | Matthew Wild
<mwild1@gmail.com> 2024-12-02 14:16:29 UTC |
| committer | Matthew Wild
<mwild1@gmail.com> 2024-12-02 14:16:29 UTC |
| parent | 92b658f5ce6b72582bbf4067bb7b27abde37e689 |
| snikket/Stanza.hx | +24 | -0 |
diff --git a/snikket/Stanza.hx b/snikket/Stanza.hx index 92afaeb..26e21ea 100644 --- a/snikket/Stanza.hx +++ b/snikket/Stanza.hx @@ -38,6 +38,18 @@ class TextNode implements NodeInterface { } } +class StanzaError { + public var type:String; + public var condition:String; + public var text:Null<String>; + + public function new(type_:String, condition_:String, ?text_:String) { + type = type_; + condition = condition_; + text = text_; + } +} + @:expose class Stanza implements NodeInterface { public var name(default, null):String = null; @@ -314,6 +326,18 @@ class Stanza implements NodeInterface { } return this; } + + public function getError():Null<StanzaError> { + final errorTag = this.getChild("error"); + if(errorTag == null) { + return null; + } + return new StanzaError( + errorTag.attr.get("type"), + errorTag.getChild(null, "urn:ietf:params:xml:ns:xmpp-stanzas")?.name, + errorTag.getChildText("text", "urn:ietf:params:xml:ns:xmpp-stanzas") + ); + } } enum IqRequestType {