watson-developer-cloud / node-red-node-watson

A collection of nodes for the IBM Watson services
Apache License 2.0
82 stars 86 forks source link

Catch node can't be used with Watson Conversation Node #328

Closed dennisnotojr closed 6 years ago

dennisnotojr commented 7 years ago

After testing errors with the WCS node, I have concluded that the catch node can't be used due to the fact that node.error is being called with just one param. node.error needs to be called with two params for the catch node to work. This probably effects the others Watson nodes as well.

Here's Nick Oleary's comment on another node that doesn't trigger the catch node.

"the node is calling node.error("message") which causes it to get logged, but is not also passing in the offending msg object which is needed to trigger the Catch node"

dennisnotojr commented 7 years ago

Here is the code where node.error only has one param

function processResponse(err, body, node, msg, config) { if (err !== null && body === null) { node.error(err); node.status({ fill: 'red', shape: 'ring', text: 'call to watson conversation service failed' }); return; } msg.payload = body;

if (config.context) {
  if (config.multiuser && msg.user) {
    node.context().flow.set('context-' + msg.user, body.context);
  } else {
    if (msg.user) {
      node.warn('msg.user ignored when multiple users not set in node');
    }
    node.context().flow.set('context', body.context);
  }
}

node.send(msg);
node.status({});

}

dennisnotojr commented 7 years ago

Here is the code to fix the problem is processResponse. Made a copy of your project and tested the code fix and catch works with this mod.

node.error(err, msg);

chughts commented 6 years ago

Thanks for this spot. I will try and wrap into the next code drop.

chughts commented 6 years ago

Implemented in 0.5.14

chughts commented 6 years ago

Released