How to detect a non delivered jabber message

We need to know when a Jabber message has not been delivered.


Extensible Messaging and Presence Protocol(XMPP): Core


10.4.3. Error Handling

If routing of a stanza to the intended recipient’s server isunsuccessful, the sender’s server MUST return an error to the sender.If resolution of the remote domain is unsuccessful, the stanza errorMUST be (Section If resolution succeeds but streamscannot be negotiated, the stanza error MUST be (Section

If stream negotiation with the intended recipient’s server issuccessful but the remote server cannot deliver the stanza to therecipient, the remote server MUST return an appropriate error to thesender by way of the sender’s server.

Specifies that error messages must be generated when a stanza is unsuccessfully sent to the recipients server. Is there a way to trap this error message, maybe with a listener, or, is there another approach to the problem that is not documented.