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

Make log message in invalid regular expressions more verbose

Make logging of erratic regular expressions more verbose to help
identification and resolving of the configuration issue:

eg.:
old: 24 Dec 18:40:09 - [error] [change:Strip kW] Invalid regex: *kW
new: 24 Dec 18:40:09 - [error] [change:Strip kW] Invalid regular
expression: /*kW/: Nothing to repeat

old: 24 Dec 20:15:57 - [error] [change:Strip kW] Invalid regex: *kW
new: 24 Dec 20:15:57 - [error] [change:Strip kW] Invalid regular
expression: /[kW/: Unterminated character class
This commit is contained in:
Frank van de Pol 2013-12-24 20:17:42 +01:00
parent 231f8b6a4d
commit b411d59d43

View File

@ -43,7 +43,7 @@ function ChangeNode(n) {
try { try {
node.re = new RegExp(from, "g"); node.re = new RegExp(from, "g");
} catch (e) { } catch (e) {
node.error("Invalid regex: "+from); node.error(e.message);
} }
if (typeof msg[node.property] === "string") { if (typeof msg[node.property] === "string") {
msg[node.property] = (msg[node.property]).replace(node.re, node.to); msg[node.property] = (msg[node.property]).replace(node.re, node.to);