Backport of COMETD-408 (allow more detailed error handling)

Hi Simone,

here the pull request for the 2.6 branch. 

Best Regards,
Florian