Error frame confusion
It looks like when an error frame is received, it is always handled by the connect error callback.
For example:
CONNECT-- server returns successSUBSCRIBE-- server returns error response e.g. permission denied- client calls
CONNECTerror callback
This is pretty confusing and hard to program against -- one would expect some sort of error callback related to the SUBSCRIBE for step 2 and 3.
I do agree. I forked previous stomp lib with all pending PR + re-write it in es6 with no major evolution to not break the API a lot. Now I would like to launch a future major release with a lot of enhancement + some test sbut I really need some free time to do it or some PRs to help me.
Actually, I think it is expected behavior. Because STOMP doesn't declare how to handle ERROR frames, and that's why src/client.js:136 allow a user to decide how to handle it properly. I agree that errorCallback is a bit confusing name, but I can't imagine better.
Also, remember that adding special heads require additional server-side enhancement(which most of the time is too hard).
I agree that errorCallback is a bit confusing name, but I can't imagine better.
What's confusing is not the name of the callback, but where it is passed in. It is passed in to the connect method, but is also called as a result of other operations like subscribe.
If there is no way for the client to distinguish between a connect and a subscribe error (which seems to be the case), then the error callback should be configured at the client level i.e. before calling connect.
@rocketraman There is no way to distinguish ERROR frames. I think it's good idea to have 1 global errorHandler per Client instance.