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

Ensure error messages are toStringed

This commit is contained in:
Nick O'Leary 2015-06-16 16:09:53 +01:00
parent 48df31d7b7
commit 9ca102cf81
8 changed files with 23 additions and 23 deletions

View File

@ -84,7 +84,7 @@ module.exports = function(RED) {
res.send(200); res.send(200);
} catch(err) { } catch(err) {
res.send(500); res.send(500);
node.error(RED._("inject.failed",{error:err})); node.error(RED._("inject.failed",{error:err.toString()}));
} }
} else { } else {
res.send(404); res.send(404);

View File

@ -40,11 +40,11 @@
&nbsp;<span id="pitype"></span> &nbsp;<span id="pitype"></span>
</div> </div>
<div class="form-row"> <div class="form-row">
<label for="node-input-intype"><i class="fa fa-level-up"></i> <span data-i18n="rpi-gpio.label.registor"></span></label> <label for="node-input-intype"><i class="fa fa-level-up"></i> <span data-i18n="rpi-gpio.label.resistor"></span></label>
<select type="text" id="node-input-intype" style="width: 150px;"> <select type="text" id="node-input-intype" style="width: 150px;">
<option value="tri" data-i18n="rpi-gpio.registor.none"></option> <option value="tri" data-i18n="rpi-gpio.resistor.none"></option>
<option value="up" data-i18n="rpi-gpio.registor.pullup"></option> <option value="up" data-i18n="rpi-gpio.resistor.pullup"></option>
<option value="down" data-i18n="rpi-gpio.registor.pulldown"></option> <option value="down" data-i18n="rpi-gpio.resistor.pulldown"></option>
</select> </select>
</div> </div>
<div class="form-row"> <div class="form-row">

View File

@ -99,7 +99,7 @@ module.exports = function(RED) {
node.child.on('error', function (err) { node.child.on('error', function (err) {
if (err.errno === "ENOENT") { node.error(RED._("rpi-gpio.errors.commandnotfound")); } if (err.errno === "ENOENT") { node.error(RED._("rpi-gpio.errors.commandnotfound")); }
else if (err.errno === "EACCES") { node.error(RED._("rpi-gpio.errors.commandnotexecutable")); } else if (err.errno === "EACCES") { node.error(RED._("rpi-gpio.errors.commandnotexecutable")); }
else { node.error(RED._("rpi-gpio.errors.error",{error:err.errnp})) } else { node.error(RED._("rpi-gpio.errors.error",{error:err.errno})) }
}); });
} }

View File

@ -183,13 +183,13 @@ module.exports = function(RED) {
}); });
server.on('error', function(err) { server.on('error', function(err) {
if (err) { if (err) {
node.error(RED._("tcpin.errors.cannot-listen",{port:node.port,error:err})); node.error(RED._("tcpin.errors.cannot-listen",{port:node.port,error:err.toString()}));
} }
}); });
server.listen(node.port, function(err) { server.listen(node.port, function(err) {
if (err) { if (err) {
node.error(RED._("tcpin.errors.cannot-listen",{port:node.port,error:err})); node.error(RED._("tcpin.errors.cannot-listen",{port:node.port,error:err.toString()}));
} else { } else {
node.log(RED._("tcpin.status.listening-port",{port:node.port})); node.log(RED._("tcpin.status.listening-port",{port:node.port}));
node.on('close', function() { node.on('close', function() {
@ -236,7 +236,7 @@ module.exports = function(RED) {
node.status({fill:"green",shape:"dot",text:RED._("common.status.connected")}); node.status({fill:"green",shape:"dot",text:RED._("common.status.connected")});
}); });
client.on('error', function (err) { client.on('error', function (err) {
node.log(RED._("tcpin.errors.error",{error:err})); node.log(RED._("tcpin.errors.error",{error:err.toString()}));
}); });
client.on('end', function (err) { client.on('end', function (err) {
}); });
@ -343,13 +343,13 @@ module.exports = function(RED) {
server.on('error', function(err) { server.on('error', function(err) {
if (err) { if (err) {
node.error(RED._("tcpin.errors.cannot-listen",{port:node.port,error:err})); node.error(RED._("tcpin.errors.cannot-listen",{port:node.port,error:err.toString()}));
} }
}); });
server.listen(node.port, function(err) { server.listen(node.port, function(err) {
if (err) { if (err) {
node.error(RED._("tcpin.errors.cannot-listen",{port:node.port,error:err})); node.error(RED._("tcpin.errors.cannot-listen",{port:node.port,error:err.toString()}));
} else { } else {
node.log(RED._("tcpin.status.listening-port",{port:node.port})); node.log(RED._("tcpin.status.listening-port",{port:node.port}));
node.on('close', function() { node.on('close', function() {

View File

@ -280,8 +280,8 @@
"return": { "return": {
"timeout": "after a fixed timeout of", "timeout": "after a fixed timeout of",
"character": "when character received is", "character": "when character received is",
"number": "a fixed number of chars:", "number": "a fixed number of chars",
"never": "keep connection open" "never": "never - keep connection open"
}, },
"status": { "status": {
"connecting": "connecting to __host__:__port__", "connecting": "connecting to __host__:__port__",
@ -499,7 +499,7 @@
"label": { "label": {
"gpiopin": "GPIO Pin", "gpiopin": "GPIO Pin",
"selectpin": "select pin", "selectpin": "select pin",
"registor": "Registor?", "resistor": "Resistor?",
"readinitial": "Read initial state of pin on deploy/restart?", "readinitial": "Read initial state of pin on deploy/restart?",
"type": "Type", "type": "Type",
"initpin": "Initialise pin state?", "initpin": "Initialise pin state?",
@ -509,7 +509,7 @@
"right": "Right", "right": "Right",
"middle": "Middle" "middle": "Middle"
}, },
"registor": { "resistor": {
"none": "none", "none": "none",
"pullup": "pullup", "pullup": "pullup",
"pulldown": "pulldown" "pulldown": "pulldown"

View File

@ -47,13 +47,13 @@ module.exports = function(RED) {
// using "binary" not {encoding:"binary"} to be 0.8 compatible for a while // using "binary" not {encoding:"binary"} to be 0.8 compatible for a while
//fs.writeFile(filename, data, {encoding:"binary"}, function (err) { //fs.writeFile(filename, data, {encoding:"binary"}, function (err) {
fs.writeFile(filename, data, "binary", function (err) { fs.writeFile(filename, data, "binary", function (err) {
if (err) { node.error(RED._("file.errors.writefail",{error:err}),msg); } if (err) { node.error(RED._("file.errors.writefail",{error:err.toString()}),msg); }
else if (RED.settings.verbose) { node.log(RED._("file.status.wrotefile",{file:filename})); } else if (RED.settings.verbose) { node.log(RED._("file.status.wrotefile",{file:filename})); }
}); });
} }
else if (this.overwriteFile === "delete") { else if (this.overwriteFile === "delete") {
fs.unlink(filename, function (err) { fs.unlink(filename, function (err) {
if (err) { node.error(RED._("file.errors.deletefail",{error:err}),msg); } if (err) { node.error(RED._("file.errors.deletefail",{error:err.toString()}),msg); }
else if (RED.settings.verbose) { node.log(RED._("file.status.deletedfile",{file:filename})); } else if (RED.settings.verbose) { node.log(RED._("file.status.deletedfile",{file:filename})); }
}); });
} }
@ -61,7 +61,7 @@ module.exports = function(RED) {
// using "binary" not {encoding:"binary"} to be 0.8 compatible for a while longer // using "binary" not {encoding:"binary"} to be 0.8 compatible for a while longer
//fs.appendFile(filename, data, {encoding:"binary"}, function (err) { //fs.appendFile(filename, data, {encoding:"binary"}, function (err) {
fs.appendFile(filename, data, "binary", function (err) { fs.appendFile(filename, data, "binary", function (err) {
if (err) { node.error(RED._("file.errors.appendfail",{error:err}),msg); } if (err) { node.error(RED._("file.errors.appendfail",{error:err.toString()}),msg); }
else if (RED.settings.verbose) { node.log(RED._("file.status.appendedfile",{file:filename})); } else if (RED.settings.verbose) { node.log(RED._("file.status.appendedfile",{file:filename})); }
}); });
} }

View File

@ -35,7 +35,7 @@ function createLibrary(type) {
} }
}).otherwise(function(err) { }).otherwise(function(err) {
if (err) { if (err) {
log.warn(log._("api.library.error-load-entry",{path:path,message:err})); log.warn(log._("api.library.error-load-entry",{path:path,message:err.toString()}));
if (err.code === 'forbidden') { if (err.code === 'forbidden') {
log.audit({event: "library.get",type:type,error:"forbidden"},req); log.audit({event: "library.get",type:type,error:"forbidden"},req);
res.send(403); res.send(403);
@ -57,7 +57,7 @@ function createLibrary(type) {
log.audit({event: "library.set",type:type},req); log.audit({event: "library.set",type:type},req);
res.send(204); res.send(204);
}).otherwise(function(err) { }).otherwise(function(err) {
log.warn(log._("api.library.error-save-entry",{path:path,message:err})); log.warn(log._("api.library.error-save-entry",{path:path,message:err.toString()}));
if (err.code === 'forbidden') { if (err.code === 'forbidden') {
log.audit({event: "library.set",type:type,error:"forbidden"},req); log.audit({event: "library.set",type:type,error:"forbidden"},req);
res.send(403); res.send(403);
@ -89,7 +89,7 @@ module.exports = {
res.send(data); res.send(data);
}).otherwise(function(err) { }).otherwise(function(err) {
if (err) { if (err) {
log.warn(log._("api.library.error-load-flow",{path:req.params[0],message:err})); log.warn(log._("api.library.error-load-flow",{path:req.params[0],message:err.toString()}));
if (err.code === 'forbidden') { if (err.code === 'forbidden') {
log.audit({event: "library.get",type:"flow",path:req.params[0],error:"forbidden"},req); log.audit({event: "library.get",type:"flow",path:req.params[0],error:"forbidden"},req);
res.send(403); res.send(403);
@ -106,7 +106,7 @@ module.exports = {
log.audit({event: "library.set",type:"flow",path:req.params[0]},req); log.audit({event: "library.set",type:"flow",path:req.params[0]},req);
res.send(204); res.send(204);
}).otherwise(function(err) { }).otherwise(function(err) {
log.warn(log._("api.library.error-save-flow",{path:req.params[0],message:err})); log.warn(log._("api.library.error-save-flow",{path:req.params[0],message:err.toString()}));
if (err.code === 'forbidden') { if (err.code === 'forbidden') {
log.audit({event: "library.set",type:"flow",path:req.params[0],error:"forbidden"},req); log.audit({event: "library.set",type:"flow",path:req.params[0],error:"forbidden"},req);
res.send(403); res.send(403);

View File

@ -58,7 +58,7 @@ var flowNodes = module.exports = {
flowNodes.startFlows(); flowNodes.startFlows();
}); });
}).otherwise(function(err) { }).otherwise(function(err) {
log.warn(log._("nodes.flows.error",{err:err})); log.warn(log._("nodes.flows.error",{message:err.toString()}));
console.log(err.stack); console.log(err.stack);
}); });
}, },