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

fix error report on node load

This commit is contained in:
Hiroyasu Nishiyama 2021-03-09 10:57:29 +09:00
parent aa5e47b462
commit 3671a70e3b

View File

@ -385,10 +385,17 @@ function loadNodeSet(node) {
var stack = err.stack; var stack = err.stack;
var message; var message;
if (stack) { if (stack) {
var i = stack.indexOf(node.file); var filePath = node.file;
try {
filePath = fs.realpathSync(filePath);
}
catch (e) {
// ignore canonicalization error
}
var i = stack.indexOf(filePath);
if (i > -1) { if (i > -1) {
var excerpt = stack.substring(i+node.file.length+1,i+node.file.length+20); var excerpt = stack.substring(i+filePath.length+1,i+filePath.length+20);
var m = /^(\d+):(\d+)/.exec(excerpt); var m = /^(\d+)/.exec(excerpt);
if (m) { if (m) {
node.err = err+" (line:"+m[1]+")"; node.err = err+" (line:"+m[1]+")";
} }