first commit

This commit is contained in:
2025-10-26 23:10:15 +08:00
commit 8f0345b7be
14961 changed files with 2356381 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import { ApplicationError, type ReportingOptions } from '@n8n/errors';
import type { Functionality, IDataObject, JsonObject } from '../../interfaces';
interface ExecutionBaseErrorOptions extends ReportingOptions {
cause?: Error;
errorResponse?: JsonObject;
}
export declare abstract class ExecutionBaseError extends ApplicationError {
description: string | null | undefined;
cause?: Error;
errorResponse?: JsonObject;
timestamp: number;
context: IDataObject;
lineNumber: number | undefined;
functionality: Functionality;
constructor(message: string, options?: ExecutionBaseErrorOptions);
toJSON?(): {
message: string;
lineNumber: number | undefined;
timestamp: number;
name: string;
description: string | null | undefined;
context: IDataObject;
cause: Error | undefined;
};
}
export {};
//# sourceMappingURL=execution-base.error.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"execution-base.error.d.ts","sourceRoot":"","sources":["../../../../src/errors/abstract/execution-base.error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE/E,UAAU,yBAA0B,SAAQ,gBAAgB;IAC3D,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,aAAa,CAAC,EAAE,UAAU,CAAC;CAC3B;AAED,8BAAsB,kBAAmB,SAAQ,gBAAgB;IAChE,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAE9B,KAAK,CAAC,EAAE,KAAK,CAAC;IAEvB,aAAa,CAAC,EAAE,UAAU,CAAC;IAE3B,SAAS,EAAE,MAAM,CAAC;IAElB,OAAO,EAAE,WAAW,CAAM;IAE1B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAE/B,aAAa,EAAE,aAAa,CAAa;gBAE7B,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,yBAA8B;IAgBpE,MAAM,CAAC;;;;;;;;;CAWP"}

View File

@@ -0,0 +1,36 @@
import { ApplicationError } from '@n8n/errors';
export class ExecutionBaseError extends ApplicationError {
description;
cause;
errorResponse;
timestamp;
context = {};
lineNumber;
functionality = 'regular';
constructor(message, options = {}) {
super(message, options);
this.name = this.constructor.name;
this.timestamp = Date.now();
const { cause, errorResponse } = options;
if (cause instanceof ExecutionBaseError) {
this.context = cause.context;
}
else if (cause && !(cause instanceof Error)) {
this.cause = cause;
}
if (errorResponse)
this.errorResponse = errorResponse;
}
toJSON() {
return {
message: this.message,
lineNumber: this.lineNumber,
timestamp: this.timestamp,
name: this.name,
description: this.description,
context: this.context,
cause: this.cause,
};
}
}
//# sourceMappingURL=execution-base.error.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"execution-base.error.js","sourceRoot":"","sources":["../../../../src/errors/abstract/execution-base.error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAyB,MAAM,aAAa,CAAC;AAStE,MAAM,OAAgB,kBAAmB,SAAQ,gBAAgB;IAChE,WAAW,CAA4B;IAE9B,KAAK,CAAS;IAEvB,aAAa,CAAc;IAE3B,SAAS,CAAS;IAElB,OAAO,GAAgB,EAAE,CAAC;IAE1B,UAAU,CAAqB;IAE/B,aAAa,GAAkB,SAAS,CAAC;IAEzC,YAAY,OAAe,EAAE,UAAqC,EAAE;QACnE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAExB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE5B,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;QACzC,IAAI,KAAK,YAAY,kBAAkB,EAAE,CAAC;YACzC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC9B,CAAC;aAAM,IAAI,KAAK,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,EAAE,CAAC;YAC/C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACpB,CAAC;QAED,IAAI,aAAa;YAAE,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACvD,CAAC;IAED,MAAM;QACL,OAAO;YACN,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,KAAK,EAAE,IAAI,CAAC,KAAK;SACjB,CAAC;IACH,CAAC;CACD"}

View File

@@ -0,0 +1,48 @@
import { ExecutionBaseError } from './execution-base.error';
import type { INode, JsonObject } from '../../interfaces';
/**
* Base class for specific NodeError-types, with functionality for finding
* a value recursively inside an error object.
*/
export declare abstract class NodeError extends ExecutionBaseError {
readonly node: INode;
messages: string[];
constructor(node: INode, error: Error | JsonObject);
/**
* Finds property through exploration based on potential keys and traversal keys.
* Depth-first approach.
*
* This method iterates over `potentialKeys` and, if the value at the key is a
* truthy value, the type of the value is checked:
* (1) if a string or number, the value is returned as a string; or
* (2) if an array,
* its string or number elements are collected as a long string,
* its object elements are traversed recursively (restart this function
* with each object as a starting point), or
* (3) if it is an object, it traverses the object and nested ones recursively
* based on the `potentialKeys` and returns a string if found.
*
* If nothing found via `potentialKeys` this method iterates over `traversalKeys` and
* if the value at the key is a traversable object, it restarts with the object as the
* new starting point (recursion).
* If nothing found for any of the `traversalKeys`, exploration continues with remaining
* `traversalKeys`.
*
* Otherwise, if all the paths have been exhausted and no value is eligible, `null` is
* returned.
*
*/
protected findProperty(jsonError: JsonObject, potentialKeys: string[], traversalKeys?: string[]): string | null;
/**
* Preserve the original error message before setting the new one
*/
protected addToMessages(message: string): void;
/**
* Set descriptive error message if code is provided or if message contains any of the common errors,
* update description to include original message plus the description
*/
protected setDescriptiveErrorMessage(message: string, messages: string[], code?: string | null, messageMapping?: {
[key: string]: string;
}): [string, string[]];
}
//# sourceMappingURL=node.error.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"node.error.d.ts","sourceRoot":"","sources":["../../../../src/errors/abstract/node.error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAe,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AA+BvE;;;GAGG;AACH,8BAAsB,SAAU,SAAQ,kBAAkB;IAIxD,QAAQ,CAAC,IAAI,EAAE,KAAK;IAHrB,QAAQ,EAAE,MAAM,EAAE,CAAM;gBAGd,IAAI,EAAE,KAAK,EACpB,KAAK,EAAE,KAAK,GAAG,UAAU;IAY1B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,SAAS,CAAC,YAAY,CACrB,SAAS,EAAE,UAAU,EACrB,aAAa,EAAE,MAAM,EAAE,EACvB,aAAa,GAAE,MAAM,EAAO,GAC1B,MAAM,GAAG,IAAI;IAqDhB;;OAEG;IACH,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAM9C;;;OAGG;IACH,SAAS,CAAC,0BAA0B,CACnC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAAE,EAClB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,EACpB,cAAc,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GACxC,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;CAkCrB"}

View File

@@ -0,0 +1,163 @@
import { ExecutionBaseError } from './execution-base.error';
import { isTraversableObject, jsonParse } from '../../utils';
/**
* Descriptive messages for common errors.
*/
const COMMON_ERRORS = {
// nodeJS errors
ECONNREFUSED: 'The service refused the connection - perhaps it is offline',
ECONNRESET: 'The connection to the server was closed unexpectedly, perhaps it is offline. You can retry the request immediately or wait and retry later.',
ENOTFOUND: 'The connection cannot be established, this usually occurs due to an incorrect host (domain) value',
ETIMEDOUT: "The connection timed out, consider setting the 'Retry on Fail' option in the node settings",
ERRADDRINUSE: 'The port is already occupied by some other application, if possible change the port or kill the application that is using it',
EADDRNOTAVAIL: 'The address is not available, ensure that you have the right IP address',
ECONNABORTED: 'The connection was aborted, perhaps the server is offline',
EHOSTUNREACH: 'The host is unreachable, perhaps the server is offline',
EAI_AGAIN: 'The DNS server returned an error, perhaps the server is offline',
ENOENT: 'The file or directory does not exist',
EISDIR: 'The file path was expected but the given path is a directory',
ENOTDIR: 'The directory path was expected but the given path is a file',
EACCES: 'Forbidden by access permissions, make sure you have the right permissions',
EEXIST: 'The file or directory already exists',
EPERM: 'Operation not permitted, make sure you have the right permissions',
// other errors
GETADDRINFO: 'The server closed the connection unexpectedly',
};
/**
* Base class for specific NodeError-types, with functionality for finding
* a value recursively inside an error object.
*/
export class NodeError extends ExecutionBaseError {
node;
messages = [];
constructor(node, error) {
const isError = error instanceof Error;
const message = isError ? error.message : '';
const options = isError ? { cause: error } : { errorResponse: error };
super(message, options);
this.node = node;
if (error instanceof NodeError) {
this.tags.reWrapped = true;
}
}
/**
* Finds property through exploration based on potential keys and traversal keys.
* Depth-first approach.
*
* This method iterates over `potentialKeys` and, if the value at the key is a
* truthy value, the type of the value is checked:
* (1) if a string or number, the value is returned as a string; or
* (2) if an array,
* its string or number elements are collected as a long string,
* its object elements are traversed recursively (restart this function
* with each object as a starting point), or
* (3) if it is an object, it traverses the object and nested ones recursively
* based on the `potentialKeys` and returns a string if found.
*
* If nothing found via `potentialKeys` this method iterates over `traversalKeys` and
* if the value at the key is a traversable object, it restarts with the object as the
* new starting point (recursion).
* If nothing found for any of the `traversalKeys`, exploration continues with remaining
* `traversalKeys`.
*
* Otherwise, if all the paths have been exhausted and no value is eligible, `null` is
* returned.
*
*/
findProperty(jsonError, potentialKeys, traversalKeys = []) {
for (const key of potentialKeys) {
let value = jsonError[key];
if (value) {
if (typeof value === 'string') {
try {
value = jsonParse(value);
}
catch (error) {
return value;
}
if (typeof value === 'string')
return value;
}
if (typeof value === 'number')
return value.toString();
if (Array.isArray(value)) {
const resolvedErrors = value
.map((jsonError) => {
if (typeof jsonError === 'string')
return jsonError;
if (typeof jsonError === 'number')
return jsonError.toString();
if (isTraversableObject(jsonError)) {
return this.findProperty(jsonError, potentialKeys);
}
return null;
})
.filter((errorValue) => errorValue !== null);
if (resolvedErrors.length === 0) {
return null;
}
return resolvedErrors.join(' | ');
}
if (isTraversableObject(value)) {
const property = this.findProperty(value, potentialKeys);
if (property) {
return property;
}
}
}
}
for (const key of traversalKeys) {
const value = jsonError[key];
if (isTraversableObject(value)) {
const property = this.findProperty(value, potentialKeys, traversalKeys);
if (property) {
return property;
}
}
}
return null;
}
/**
* Preserve the original error message before setting the new one
*/
addToMessages(message) {
if (message && !this.messages.includes(message)) {
this.messages.push(message);
}
}
/**
* Set descriptive error message if code is provided or if message contains any of the common errors,
* update description to include original message plus the description
*/
setDescriptiveErrorMessage(message, messages, code, messageMapping) {
let newMessage = message;
if (messageMapping) {
for (const [mapKey, mapMessage] of Object.entries(messageMapping)) {
if ((message || '').toUpperCase().includes(mapKey.toUpperCase())) {
newMessage = mapMessage;
messages.push(message);
break;
}
}
if (newMessage !== message) {
return [newMessage, messages];
}
}
// if code is provided and it is in the list of common errors set the message and return early
if (code && typeof code === 'string' && COMMON_ERRORS[code.toUpperCase()]) {
newMessage = COMMON_ERRORS[code];
messages.push(message);
return [newMessage, messages];
}
// check if message contains any of the common errors and set the message and description
for (const [errorCode, errorDescriptiveMessage] of Object.entries(COMMON_ERRORS)) {
if ((message || '').toUpperCase().includes(errorCode.toUpperCase())) {
newMessage = errorDescriptiveMessage;
messages.push(message);
break;
}
}
return [newMessage, messages];
}
}
//# sourceMappingURL=node.error.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"node.error.js","source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