mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Restore File In node behaviour of sending msg on error
This commit is contained in:
parent
f7bb4a7d60
commit
47e2707fd3
@ -172,7 +172,11 @@ module.exports = function(RED) {
|
||||
}
|
||||
})
|
||||
.on('error', function(err) {
|
||||
node.error('Error while reading file.', msg);
|
||||
node.error(err, msg);
|
||||
var sendMessage = RED.util.cloneMessage(msg);
|
||||
delete sendMessage.payload;
|
||||
sendMessage.error = err;
|
||||
node.send(sendMessage);
|
||||
})
|
||||
.on('end', function() {
|
||||
if (node.chunk === false) {
|
||||
|
@ -495,21 +495,31 @@ describe('file Nodes', function() {
|
||||
});
|
||||
|
||||
it('should handle a file read error', function(done) {
|
||||
var flow = [{id:"fileInNode1", type:"file in", name: "fileInNode", "filename":"badfile", "format":""}];
|
||||
var flow = [{id:"fileInNode1", type:"file in", name: "fileInNode", "filename":"badfile", "format":"", wires:[["n2"]]},
|
||||
{id:"n2", type:"helper"}
|
||||
];
|
||||
helper.load(fileNode, flow, function() {
|
||||
var n1 = helper.getNode("fileInNode1");
|
||||
setTimeout(function() {
|
||||
var logEvents = helper.log().args.filter(function(evt) {
|
||||
return evt[0].type == "file in";
|
||||
});
|
||||
logEvents.should.have.length(1);
|
||||
logEvents[0][0].should.have.a.property('msg');
|
||||
logEvents[0][0].msg.toString().should.startWith("Error");
|
||||
done();
|
||||
},wait);
|
||||
var n2 = helper.getNode("n2");
|
||||
|
||||
n2.on("input", function(msg) {
|
||||
try {
|
||||
msg.should.not.have.property('payload');
|
||||
msg.should.have.property("error");
|
||||
msg.error.should.have.property("code","ENOENT");
|
||||
var logEvents = helper.log().args.filter(function(evt) {
|
||||
return evt[0].type == "file in";
|
||||
});
|
||||
logEvents.should.have.length(1);
|
||||
logEvents[0][0].should.have.a.property('msg');
|
||||
logEvents[0][0].msg.toString().should.startWith("Error");
|
||||
done();
|
||||
} catch(err) {
|
||||
done(err);
|
||||
}
|
||||
});
|
||||
n1.receive({payload:""});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user