I'm using smack 4.1.4, and I'm having trouble parsing an IQ Error stanza.
According to the spec @ Extensible Messaging and Presence Protocol (XMPP): Core an error stanza is of the form ...
<stanza-kind to='sender' type='error'>
[RECOMMENDED to include sender XML here]
<text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' xml:lang='langcode'>
OPTIONAL descriptive text
[OPTIONAL application-specific condition element]
So, I've got two packets which may look something like ...
A standard result IQ stanza looks something like ...
<iq to="someone" from="sender" type="result">
... rest of result XML ...
Whilst an error IQ stanza looks very similar (as it includes the sender XML)
<iq to="someone" from="sender" type="error">
... rest of sender XML ...
And I can't work out how to write a IQProvider for it. My problem is that there's no way in advance of knowing if it's an error or result IQ; the IQProvider class that I'm extending doesn't give me access to the parent <iq> element, so I can't check the IQ type attribute. If I read the next item after the end of the command tag to see if it's an <error>, then for the result IQ stanza I've just pulled the </iq> item and the Provider.parse() blows up when it calls ParserUtils.forwardToEndTagOfDepth(...) as we've gone too far already.
I'm sure it must be possible to properly parse an error IQ of this style, but I can't figure out - can someone point me in the right direction?