@rxap/n8n-utilities
Version:
This package provides utility functions and classes for n8n nodes, including custom authentication methods (Bearer Auth, Oauth2 Proxy Auth, Base URL), a decorator for capturing execution errors, and base classes for creating nodes from OpenAPI specificati
36 lines • 1.58 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CaptureExecutionError = CaptureExecutionError;
const utilities_1 = require("@rxap/utilities");
function CaptureExecutionError() {
return (target, propertyKey, descriptor) => {
const originalMethod = descriptor.value;
descriptor.value = function (...args) {
// Call the original method with the correct 'this' context
const result = originalMethod.apply(this, args);
// Check if the result is a Promise
if (result && (0, utilities_1.isPromise)(result)) {
if (this.continueOnFail()) {
return result.catch((error) => {
const payload = { json: error, error };
return [[payload]];
});
}
else {
return result.then((output) => {
if (output.some(item => item === null || item === void 0 ? void 0 : item.some(item => item === null || item === void 0 ? void 0 : item.error))) {
throw output.find(item => item.some(item => item.error)).find(item => item.error).error;
}
return output;
});
}
}
else {
// If it's not a Promise, return the result directly
return result;
}
};
return descriptor;
};
}
//# sourceMappingURL=capture-execution-error.decorator.js.map