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,10 +495,18 @@ 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 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";
|
||||
});
|
||||
@ -506,10 +514,12 @@ describe('file Nodes', function() {
|
||||
logEvents[0][0].should.have.a.property('msg');
|
||||
logEvents[0][0].msg.toString().should.startWith("Error");
|
||||
done();
|
||||
},wait);
|
||||
} catch(err) {
|
||||
done(err);
|
||||
}
|
||||
});
|
||||
n1.receive({payload:""});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user