Smack: StanzaError and StreamError should have a way to give human-readable error messages

The StanzaError.toString() call will yield a string like “XMPPError: not-allowed - cancel”

This is suitable for internal logging, but it would be great to have a method that returns a human-readable string for the actual error cause, which can be shown in an XMPP client. It should include the <text> element of the error if provided, or an understandable representation of the technical enums otherwise.

Edit: apparently you can’t comment any more after a month, so editing this in. The same kind of problem exists with StreamError where a long and ugly mandatory “explanation” link is added to the human readable part in the StreamErrorException constructor.

That sounds in general like a good idea.

I wonder how a good API would look like, e.g. would the method take a language parameter to show the best matching language? How to determine the “best matching” language?

Not sure if this is feasible, but if it is, then it would sure be great.

I suppose it should take a Locale and try to find the best match for that language. If that fails, you still can return the default language code from the server.

Some discussion with XMPP server admins indicated that normally the server is responsible for providing a human-readable error message, ideally in the xml:lang of the stream. Some implementations are better at this than others, but I suppose we don’t have a way to define the xml:lang when establishing a connection?

Not yet, you are the first to ask for it as far as I remember. It should be trivial to add to connection configuration. Patches welcome.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.