rwaldron / particle-io

Particle/Spark Core/Photon IO Plugin for Johnny-Five
http://johnny-five.io
MIT License
173 stars 31 forks source link

Error messages not helpful in certain situations #44

Open makenai opened 9 years ago

makenai commented 9 years ago

While setting up at RobotsConf, I got:

'Error code 400 - error connecting to cloud' when my Spark token was expired.

Then, 'Error code 404 - error connecting to cloud' when Spark returned a 'variable not found' error (not displayed - had to dump the error body out) indicating I had an old or nonexistent version of VoodooSpark installed.

These could return some more useful hints / messages.

makenai commented 9 years ago

Both of the errors happened around line 280 in spark.js:

  if (res.statusCode === 200) {
      var data = JSON.parse(body);
      if (data.error) {
        err = "ERROR: " + data.code + " " + data.error_description;
      }
      if (handler) {
        handler(err, data);
      }
  } else {
   // Please consider adding the body message below
    err = errors.cloud + ": code: " + res.statusCode;
    if (handler) {
      handler(new Error(err));
    } else {
      throw new Error(err);
    }
  }