metajack/strophejs — pull request #93 by jpcaruana (2012-08-09 10:14:16+00:00)
Title: HTTP errors events

As seen here http://stackoverflow.com/questions/8285053/why-there-is-no-error-thrown-with-strophe-js, Strophes handles HTTP connections and errors, but the client isn't notified when an HTTP error occurs. You might want to implement specific behaviour on a specific error (I do on 502 errors for instance), and this pull request fires a 'strophe-http-xxx-error' on a xxx HTTP error. I propose this request because I don't want to patch ``_hitError`` in my client code every time I use Strophe.

This a (safe) and very simple jQuery implementation, because I use jQuery myself. It should not fail if jQuery is not defined, but in this case it won't fire anything.

Ex : do something on 502 HTTP errors :

$(document).bind('strophe-http-502-error', function (event) {
// do something useful here
});