mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
⚡ Add line numbers to errors
This commit is contained in:
parent
fa760ee26b
commit
0f1b8779e4
|
@ -127,6 +127,18 @@ return items;`,
|
||||||
if (this.continueOnFail()) {
|
if (this.continueOnFail()) {
|
||||||
items=[{json:{ error: error.message }}];
|
items=[{json:{ error: error.message }}];
|
||||||
} else {
|
} else {
|
||||||
|
// Try to find the lien number which contains the error and attach to error message
|
||||||
|
const stackLines = error.stack.split('\n');
|
||||||
|
if (stackLines.length > 0) {
|
||||||
|
const lineParts = stackLines[1].split(':');
|
||||||
|
if (lineParts.length > 2) {
|
||||||
|
const lineNumber = lineParts.splice(-2, 1);
|
||||||
|
if (!isNaN(lineNumber)) {
|
||||||
|
error.message = `${error.message} [Line ${lineNumber}]`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,6 +120,21 @@ return item;`,
|
||||||
returnData.push({json:{ error: error.message }});
|
returnData.push({json:{ error: error.message }});
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
// Try to find the lien number which contains the error and attach to error message
|
||||||
|
const stackLines = error.stack.split('\n');
|
||||||
|
if (stackLines.length > 0) {
|
||||||
|
const lineParts = stackLines[1].split(':');
|
||||||
|
if (lineParts.length > 2) {
|
||||||
|
const lineNumber = lineParts.splice(-2, 1);
|
||||||
|
if (!isNaN(lineNumber)) {
|
||||||
|
error.message = `${error.message} [Line ${lineNumber} | Item Index: ${itemIndex}]`;
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
error.message = `${error.message} [Item Index: ${itemIndex}]`;
|
||||||
|
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue