paho.mqtt.javascript icon indicating copy to clipboard operation
paho.mqtt.javascript copied to clipboard

throw exceptions as last resort

Open boneskull opened this issue 7 years ago • 0 comments

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).

boneskull avatar Feb 21 '18 18:02 boneskull