1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Invoke catch node only when msg is provided

This commit is contained in:
Nick O'Leary 2015-02-20 22:59:48 +00:00
parent c5c404ea05
commit 00d0f8cfc7
3 changed files with 4 additions and 22 deletions

View File

@ -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 = {};

View File

@ -201,7 +201,9 @@ Node.prototype.warn = function(msg) {
Node.prototype.error = function(logMessage,msg) {
logMessage = logMessage || "";
log_helper(this, Log.ERROR, logMessage);
if (msg) {
flows.handleError(this,logMessage,msg);
}
};
/**

View File

@ -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"]},