I am currently working on my own XMPP library and therefore put some thoughts into exception handling as well:
For the connect() method I just throw an IOException, which could also be an java.net.UnknownHostException, e.g. if the connection to a port failed. Usually during stream negotiation, there is no stream error, so I thought this is sufficient. Not sure, if this is good, but in the worst case you could still pass a cause to IOException.
For the login() method I throw a javax.security.auth.login.LoginException.
For more specific errors during SASL negotation, I throw sub-exceptions like javax.security.auth.login.AccountLockedException () or javax.security.auth.login.CredentialExpiredException () or just
Every other SASL failure either should not happen (e.g. ) or one could make own subclasses of LoginException, if really needed.
Other exceptions during login, which can happen during resource binding (stanza errors, e.g. ) are also handled via LoginException currently (text only). But I am not sure, if this is optimal.
Then there’s also compression (XEP-138) in between SASL and resource binding (XEP-170), which might produce failures. If that happens, I just ignore it (XEP-138: “the initiating entity is free to retry the compression negotiation if it fails.”)
And what do you mean by a temporary or permanent exception?