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

Extract line number if available from node load errors

This commit is contained in:
Nick O'Leary 2017-01-30 09:37:08 +00:00
parent 939768eec0
commit 0643f149b7
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -315,6 +315,18 @@ function loadNodeSet(node) {
return loadPromise; return loadPromise;
} catch(err) { } catch(err) {
node.err = err; node.err = err;
var stack = err.stack;
var message;
if (stack) {
var i = stack.indexOf(node.file);
if (i > -1) {
var excerpt = stack.substring(i+node.file.length+1,i+node.file.length+20);
var m = /^(\d+):(\d+)/.exec(excerpt);
if (m) {
node.err = err+" (line:"+m[1]+")";
}
}
}
return when.resolve(node); return when.resolve(node);
} }
} }