paho.mqtt.javascript
paho.mqtt.javascript copied to clipboard
throw exceptions as last resort
In many places throughout the client, we're throwing exceptions where exceptions don't need to be thrown. It's more user-friendly to simply choose a default, coerce a type, warn, or just ignore some behaviors.
For example:
- If the client is already connected, there's no need to throw an exception if
connect()is called again. A warning would suffice, if anything. - Don't validate types up-front; choose sane defaults, let JS coerce types if possible, and throw its own
TypeErrors or exceptions if that must happen. Document the API (audit the docstrings).