mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(Code Node): Error formatting fix (#16719)
This commit is contained in:
@@ -28,15 +28,16 @@ export class ExecutionError extends ApplicationError {
|
||||
* Populate error `message` and `description` from error `stack`.
|
||||
*/
|
||||
private populateFromStack() {
|
||||
const stackRows = this.stack.split('\n');
|
||||
const stackRows = this.stack && typeof this.stack === 'string' ? this.stack.split('\n') : [];
|
||||
|
||||
if (stackRows.length === 0) {
|
||||
this.message = 'Unknown error';
|
||||
return;
|
||||
}
|
||||
|
||||
const messageRow = stackRows.find((line) => line.includes('Error:'));
|
||||
const lineNumberRow = stackRows.find((line) => line.includes('Code:'));
|
||||
const lineNumberDisplay = this.toLineNumberDisplay(lineNumberRow);
|
||||
const lineNumberDisplay = this.toLineNumberDisplay(lineNumberRow) || '';
|
||||
|
||||
if (!messageRow) {
|
||||
this.message = `Unknown error ${lineNumberDisplay}`;
|
||||
@@ -52,7 +53,7 @@ export class ExecutionError extends ApplicationError {
|
||||
return;
|
||||
}
|
||||
|
||||
this.message = `${errorDetails} ${lineNumberDisplay}`;
|
||||
this.message = `${errorDetails} ${lineNumberDisplay}`.trim();
|
||||
}
|
||||
|
||||
private toLineNumberDisplay(lineNumberRow?: string) {
|
||||
@@ -74,10 +75,16 @@ export class ExecutionError extends ApplicationError {
|
||||
private toErrorDetailsAndType(messageRow?: string) {
|
||||
if (!messageRow) return [null, null];
|
||||
|
||||
const [errorDetails, errorType] = messageRow
|
||||
.split(':')
|
||||
.reverse()
|
||||
.map((i) => i.trim());
|
||||
// Remove "Error: " prefix added by stacktrace formatting
|
||||
messageRow = messageRow.replace(/^Error: /, '');
|
||||
|
||||
const colonIndex = messageRow.indexOf(': ');
|
||||
if (colonIndex === -1) {
|
||||
return [messageRow.trim(), null];
|
||||
}
|
||||
|
||||
const errorType = messageRow.substring(0, colonIndex).trim();
|
||||
const errorDetails = messageRow.substring(colonIndex + 2).trim();
|
||||
|
||||
return [errorDetails, errorType === 'Error' ? null : errorType];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user