Skip to content

Commit

Permalink
Invoke catch node only when msg is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
knolleary committed Feb 26, 2015
1 parent c5c404e commit 00d0f8c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 22 deletions.
2 changes: 1 addition & 1 deletion red/nodes/Flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ Flow.prototype.diffFlow = function(config) {

Flow.prototype.handleError = function(node,logMessage,msg) {
var errorMessage;
if (typeof msg !== "undefined") {
if (msg) {
errorMessage = redUtil.cloneMessage(msg);
} else {
errorMessage = {};
Expand Down
4 changes: 3 additions & 1 deletion red/nodes/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ Node.prototype.warn = function(msg) {
Node.prototype.error = function(logMessage,msg) {
logMessage = logMessage || "";
log_helper(this, Log.ERROR, logMessage);
flows.handleError(this,logMessage,msg);
if (msg) {
flows.handleError(this,logMessage,msg);
}
};

/**
Expand Down
20 changes: 0 additions & 20 deletions test/red/nodes/Flow_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -869,26 +869,6 @@ describe('Flow', function() {
done();
});

it("reports error with undefined message object",function(done) {
var config = [
{id:"1",type:"test",z:"tab1",name:"a",wires:["2"]},
{id:"2",type:"catch",z:"tab1",wires:[[]]},
{id:"3",type:"catch",z:"tab2",wires:[[]]}
];
var flow = new Flow(config);
flow.start();
flow.handleError(getNode(1),"test error");
var n2 = getNode(2);
n2.handled.should.have.lengthOf(1);
n2.handled[0].should.have.property("error");
n2.handled[0].error.should.have.property("message","test error");
n2.handled[0].error.should.have.property("source");
n2.handled[0].error.source.should.have.property("id","1");
n2.handled[0].error.source.should.have.property("type","test");
getNode(3).handled.should.have.lengthOf(0);
done();
});

it("reports error with Error object",function(done) {
var config = [
{id:"1",type:"test",z:"tab1",name:"a",wires:["2"]},
Expand Down

0 comments on commit 00d0f8c

Please sign in to comment.