message: Return an error if FB returns error in the result
diff: @@ -697,9 +697,24 @@ function Facebookbot(configuration) {
  facebook_botkit.log('Could not configure messenger profile');
  reject(err);
  } else {
  - facebook_botkit.debug('Successfully configured messenger profile', message);
  + var results = null;
  + try {
  + results = JSON.parse(body);
  + } catch (err) {
  + facebook_botkit.log('ERROR in messenger profile API call: Could not parse JSON', err, body);
  + reject(err);
  + }
  +
  + if (results) {
  + if (results.error) {
  + facebook_botkit.log('ERROR in messenger profile API call: ', results.error.message);
  + reject(results.error);
  + } else {
  + facebook_botkit.debug('Successfully configured messenger profile ', body);
  resolve(message);
  }
  + }
  + }
  });
  });
  },
  @@ -715,16 +730,29 @@ function Facebookbot(configuration) {
  function(err, res, body) {
  if (err) {
  facebook_botkit.log('Could not get messenger profile');
  - if (cb) {
  - cb(err);
  + if (cb) cb(err)
  + else reject(err)
  + } else {
  + var results = null;
  + try {
  + results = JSON.parse(body);
  + } catch (err) {
  + facebook_botkit.log('ERROR in messenger profile API call: Could not parse JSON', err, body);
  + if (cb) cb(err)
  + else reject(err)
  }
  - reject(err);
  +
  + if (results) {
  + if (results.error) {
  + facebook_botkit.log('ERROR in messenger profile API call: ', results.error.message);
  + if (cb) cb(results.error)
  + else reject(results.error)
  } else {
  facebook_botkit.debug('Successfully got messenger profile ', body);
  - if (cb) {
  - cb(null, body);
  + if (cb) cb(null, body)
  + else resolve(body)
  + }
  }
  - resolve(body);
  }
  });
  });
  