mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
✨ Improve node error handling (#1309)
* Add path mapping and response error interfaces * Add error handling and throwing functionality * Refactor error handling into a single function * Re-implement error handling in Hacker News node * Fix linting details * Re-implement error handling in Spotify node * Re-implement error handling in G Suite Admin node * 🚧 create basic setup NodeError * 🚧 add httpCodes * 🚧 add path priolist * 🚧 handle statusCode in error, adjust interfaces * 🚧 fixing type issues w/Ivan * 🚧 add error exploration * 👔 fix linter issues * 🔧 improve object check * 🚧 remove path passing from NodeApiError * 🚧 add multi error + refactor findProperty method * 👔 allow any * 🔧 handle multi error message callback * ⚡ change return type of callback * ⚡ add customCallback to MultiError * 🚧 refactor to use INode * 🔨 handle arrays, continue search after first null property found * 🚫 refactor method access * 🚧 setup NodeErrorView * ⚡ change timestamp to Date.now * 📚 Add documentation for methods and constants * 🚧 change message setting * 🚚 move NodeErrors to workflow * ✨ add new ErrorView for Nodes * 🎨 improve error notification * 🎨 refactor interfaces * ⚡ add WorkflowOperationError, refactor error throwing * 👕 fix linter issues * 🎨 rename param * 🐛 fix handling normal errors * ⚡ add usage of NodeApiError * 🎨 fix throw new error instead of constructor * 🎨 remove unnecessary code/comments * 🎨 adjusted spacing + updated status messages * 🎨 fix tab indentation * ✨ Replace current errors with custom errors (#1576) * ⚡ Introduce NodeApiError in catch blocks * ⚡ Introduce NodeOperationError in nodes * ⚡ Add missing errors and remove incompatible * ⚡ Fix NodeOperationError in incompatible nodes * 🔧 Adjust error handling in missed nodes PayPal, FileMaker, Reddit, Taiga and Facebook Graph API nodes * 🔨 Adjust Strava Trigger node error handling * 🔨 Adjust AWS nodes error handling * 🔨 Remove duplicate instantiation of NodeApiError * 🐛 fix strava trigger node error handling * Add XML parsing to NodeApiError constructor (#1633) * 🐛 Remove type annotation from catch variable * ✨ Add XML parsing to NodeApiError * ⚡ Simplify error handling in Rekognition node * ⚡ Pass in XML flag in generic functions * 🔥 Remove try/catch wrappers at call sites * 🔨 Refactor setting description from XML * 🔨 Refactor let to const in resource loaders * ⚡ Find property in parsed XML * ⚡ Change let to const * 🔥 Remove unneeded try/catch block * 👕 Fix linting issues * 🐛 Fix errors from merge conflict resolution * ⚡ Add custom errors to latest contributions * 👕 Fix linting issues * ⚡ Refactor MongoDB helpers for custom errors * 🐛 Correct custom error type * ⚡ Apply feedback to A nodes * ⚡ Apply feedback to missed A node * ⚡ Apply feedback to B-D nodes * ⚡ Apply feedback to E-F nodes * ⚡ Apply feedback to G nodes * ⚡ Apply feedback to H-L nodes * ⚡ Apply feedback to M nodes * ⚡ Apply feedback to P nodes * ⚡ Apply feedback to R nodes * ⚡ Apply feedback to S nodes * ⚡ Apply feedback to T nodes * ⚡ Apply feedback to V-Z nodes * ⚡ Add HTTP code to iterable node error * 🔨 Standardize e as error * 🔨 Standardize err as error * ⚡ Fix error handling for non-standard nodes Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -431,7 +432,7 @@ export class ActiveCampaign implements INodeType {
|
||||
addAdditionalFields(body.contact as IDataObject, updateFields);
|
||||
|
||||
} else {
|
||||
throw new Error(`The operation "${operation}" is not known`);
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known`);
|
||||
}
|
||||
} else if (resource === 'account') {
|
||||
if (operation === 'create') {
|
||||
@@ -512,7 +513,7 @@ export class ActiveCampaign implements INodeType {
|
||||
addAdditionalFields(body.account as IDataObject, updateFields);
|
||||
|
||||
} else {
|
||||
throw new Error(`The operation "${operation}" is not known`);
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known`);
|
||||
}
|
||||
} else if (resource === 'accountContact') {
|
||||
if (operation === 'create') {
|
||||
@@ -562,7 +563,7 @@ export class ActiveCampaign implements INodeType {
|
||||
endpoint = `/api/3/accountContacts/${accountContactId}`;
|
||||
|
||||
} else {
|
||||
throw new Error(`The operation "${operation}" is not known`);
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known`);
|
||||
}
|
||||
} else if (resource === 'contactTag') {
|
||||
if (operation === 'add') {
|
||||
@@ -592,7 +593,7 @@ export class ActiveCampaign implements INodeType {
|
||||
endpoint = `/api/3/contactTags/${contactTagId}`;
|
||||
|
||||
} else {
|
||||
throw new Error(`The operation "${operation}" is not known`);
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known`);
|
||||
}
|
||||
} else if (resource === 'contactList') {
|
||||
if (operation === 'add') {
|
||||
@@ -630,7 +631,7 @@ export class ActiveCampaign implements INodeType {
|
||||
dataKey = 'contacts';
|
||||
|
||||
} else {
|
||||
throw new Error(`The operation "${operation}" is not known`);
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known`);
|
||||
}
|
||||
} else if (resource === 'list') {
|
||||
if (operation === 'getAll') {
|
||||
@@ -732,7 +733,7 @@ export class ActiveCampaign implements INodeType {
|
||||
addAdditionalFields(body.tag as IDataObject, updateFields);
|
||||
|
||||
} else {
|
||||
throw new Error(`The operation "${operation}" is not known`);
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known`);
|
||||
}
|
||||
} else if (resource === 'deal') {
|
||||
if (operation === 'create') {
|
||||
@@ -851,7 +852,7 @@ export class ActiveCampaign implements INodeType {
|
||||
endpoint = `/api/3/deals/${dealId}/notes/${dealNoteId}`;
|
||||
|
||||
} else {
|
||||
throw new Error(`The operation "${operation}" is not known`);
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known`);
|
||||
}
|
||||
} else if (resource === 'connection') {
|
||||
if (operation === 'create') {
|
||||
@@ -926,7 +927,7 @@ export class ActiveCampaign implements INodeType {
|
||||
endpoint = `/api/3/connections`;
|
||||
|
||||
} else {
|
||||
throw new Error(`The operation "${operation}" is not known`);
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known`);
|
||||
}
|
||||
} else if (resource === 'ecommerceOrder') {
|
||||
if (operation === 'create') {
|
||||
@@ -1024,7 +1025,7 @@ export class ActiveCampaign implements INodeType {
|
||||
endpoint = `/api/3/ecomOrders`;
|
||||
|
||||
} else {
|
||||
throw new Error(`The operation "${operation}" is not known`);
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known`);
|
||||
}
|
||||
} else if (resource === 'ecommerceCustomer') {
|
||||
if (operation === 'create') {
|
||||
@@ -1114,7 +1115,7 @@ export class ActiveCampaign implements INodeType {
|
||||
endpoint = `/api/3/ecomCustomers`;
|
||||
|
||||
} else {
|
||||
throw new Error(`The operation "${operation}" is not known`);
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known`);
|
||||
}
|
||||
} else if (resource === 'ecommerceOrderProducts') {
|
||||
if (operation === 'getByProductId') {
|
||||
@@ -1160,11 +1161,11 @@ export class ActiveCampaign implements INodeType {
|
||||
endpoint = `/api/3/ecomOrderProducts`;
|
||||
|
||||
} else {
|
||||
throw new Error(`The operation "${operation}" is not known`);
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known`);
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new Error(`The resource "${resource}" is not known!`);
|
||||
throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`);
|
||||
}
|
||||
|
||||
let responseData;
|
||||
|
||||
@@ -116,7 +116,7 @@ export class ActiveCampaignTrigger implements INodeType {
|
||||
const endpoint = `/api/3/webhooks/${webhookData.webhookId}`;
|
||||
try {
|
||||
await activeCampaignApiRequest.call(this, 'GET', endpoint, {});
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject, ILoadOptionsFunctions, INodeProperties,
|
||||
IDataObject, ILoadOptionsFunctions, INodeProperties, NodeApiError, NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { OptionsWithUri } from 'request';
|
||||
@@ -28,7 +28,7 @@ export interface IProduct {
|
||||
export async function activeCampaignApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: IDataObject, query?: IDataObject, dataKey?: string): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('activeCampaignApi');
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
if (query === undefined) {
|
||||
@@ -53,7 +53,7 @@ export async function activeCampaignApiRequest(this: IHookFunctions | IExecuteFu
|
||||
const responseData = await this.helpers.request!(options);
|
||||
|
||||
if (responseData.success === false) {
|
||||
throw new Error(`ActiveCampaign error response: ${responseData.error} (${responseData.error_info})`);
|
||||
throw new NodeApiError(this.getNode(), responseData);
|
||||
}
|
||||
|
||||
if (dataKey === undefined) {
|
||||
@@ -63,13 +63,7 @@ export async function activeCampaignApiRequest(this: IHookFunctions | IExecuteFu
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
if (error.statusCode === 403) {
|
||||
// Return a clear error
|
||||
throw new Error('The ActiveCampaign credentials are not valid!');
|
||||
}
|
||||
|
||||
// If that data does not exist for some reason return the actual error
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
ILoadOptionsFunctions,
|
||||
IWebhookFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IDataObject } from 'n8n-workflow';
|
||||
import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow';
|
||||
|
||||
export async function acuitySchedulingApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
const authenticationMethod = this.getNodeParameter('authentication', 0);
|
||||
@@ -27,7 +27,7 @@ export async function acuitySchedulingApiRequest(this: IHookFunctions | IExecute
|
||||
if (authenticationMethod === 'apiKey') {
|
||||
const credentials = this.getCredentials('acuitySchedulingApi');
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
options.auth = {
|
||||
@@ -42,6 +42,6 @@ export async function acuitySchedulingApiRequest(this: IHookFunctions | IExecute
|
||||
return await this.helpers.requestOAuth2!.call(this, 'acuitySchedulingOAuth2Api', options, true);
|
||||
}
|
||||
} catch (error) {
|
||||
throw new Error('Acuity Scheduling Error: ' + error.message);
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IWebhookResponseData,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -187,7 +188,7 @@ export class AffinityTrigger implements INodeType {
|
||||
const webhookUrl = this.getNodeWebhookUrl('default') as string;
|
||||
|
||||
if (webhookUrl.includes('%20')) {
|
||||
throw new Error('The name of the Affinity Trigger Node is not allowed to contain any spaces!');
|
||||
throw new NodeOperationError(this.getNode(), 'The name of the Affinity Trigger Node is not allowed to contain any spaces!');
|
||||
}
|
||||
|
||||
const events = this.getNodeParameter('events') as string[];
|
||||
|
||||
@@ -12,6 +12,8 @@ import {
|
||||
IDataObject,
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function affinityApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
@@ -19,7 +21,7 @@ export async function affinityApiRequest(this: IExecuteFunctions | IWebhookFunct
|
||||
const credentials = this.getCredentials('affinityApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const apiKey = `:${credentials.apiKey}`;
|
||||
@@ -47,11 +49,7 @@ export async function affinityApiRequest(this: IExecuteFunctions | IWebhookFunct
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
if (error.response) {
|
||||
const errorMessage = error.response.body.message || error.response.body.description || error.message;
|
||||
throw new Error(`Affinity error response [${error.statusCode}]: ${errorMessage}`);
|
||||
}
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@ import {
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -149,7 +150,7 @@ export class AgileCrm implements INodeType {
|
||||
Object.assign(body, JSON.parse(additionalFieldsJson));
|
||||
|
||||
} else {
|
||||
throw new Error('Additional fields must be a valid JSON');
|
||||
throw new NodeOperationError(this.getNode(), 'Additional fields must be a valid JSON');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,7 +306,7 @@ export class AgileCrm implements INodeType {
|
||||
Object.assign(body, JSON.parse(additionalFieldsJson));
|
||||
|
||||
} else {
|
||||
throw new Error('Additional fields must be a valid JSON');
|
||||
throw new NodeOperationError(this.getNode(), 'Additional fields must be a valid JSON');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -483,7 +484,7 @@ export class AgileCrm implements INodeType {
|
||||
if (validateJSON(additionalFieldsJson) !== undefined) {
|
||||
Object.assign(body, JSON.parse(additionalFieldsJson));
|
||||
} else {
|
||||
throw new Error('Additional fields must be a valid JSON');
|
||||
throw new NodeOperationError(this.getNode(), 'Additional fields must be a valid JSON');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -525,7 +526,7 @@ export class AgileCrm implements INodeType {
|
||||
Object.assign(body, JSON.parse(additionalFieldsJson));
|
||||
|
||||
} else {
|
||||
throw new Error('Additional fields must be valid JSON');
|
||||
throw new NodeOperationError(this.getNode(), 'Additional fields must be valid JSON');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IDataObject, NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
import { IContactUpdate } from './ContactInterface';
|
||||
|
||||
@@ -39,7 +39,7 @@ export async function agileCrmApiRequest(this: IHookFunctions | IExecuteFunction
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
throw new Error(`AgileCRM error response: ${error.message}`);
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -114,9 +114,9 @@ export async function agileCrmApiRequestUpdate(this: IHookFunctions | IExecuteFu
|
||||
|
||||
} catch (error) {
|
||||
if (successfulUpdates.length === 0) {
|
||||
throw new Error(`AgileCRM error response: ${error.message}`);
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
} else {
|
||||
throw new Error(`Not all properties updated. Updated properties: ${successfulUpdates.join(', ')} \n \nAgileCRM error response: ${error.message}`);
|
||||
throw new NodeApiError(this.getNode(), error, { message: `Not all properties updated. Updated properties: ${successfulUpdates.join(', ')}`, description: error.message, httpCode: error.statusCode });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -636,7 +637,7 @@ export class Airtable implements INodeType {
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new Error(`The operation "${operation}" is not known!`);
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`);
|
||||
}
|
||||
|
||||
return [this.helpers.returnJsonArray(returnData)];
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -170,7 +171,7 @@ export class AirtableTrigger implements INodeType {
|
||||
|
||||
if (Array.isArray(records) && records.length) {
|
||||
if (this.getMode() === 'manual' && records[0].fields[triggerField] === undefined) {
|
||||
throw new Error(`The Field "${triggerField}" does not exist.`);
|
||||
throw new NodeOperationError(this.getNode(), `The Field "${triggerField}" does not exist.`);
|
||||
}
|
||||
|
||||
if (downloadAttachments === true) {
|
||||
|
||||
@@ -13,6 +13,8 @@ import {
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
IPollFunctions,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
|
||||
@@ -41,7 +43,7 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa
|
||||
const credentials = this.getCredentials('airtableApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
query = query || {};
|
||||
@@ -73,23 +75,7 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
if (error.statusCode === 401) {
|
||||
// Return a clear error
|
||||
throw new Error('The Airtable credentials are not valid!');
|
||||
}
|
||||
|
||||
if (error.response && error.response.body && error.response.body.error) {
|
||||
// Try to return the error prettier
|
||||
|
||||
const airtableError = error.response.body.error;
|
||||
|
||||
if (airtableError.type && airtableError.message) {
|
||||
throw new Error(`Airtable error response [${airtableError.type}]: ${airtableError.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Expected error data did not get returned so rhow the actual error
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export class Amqp implements INodeType {
|
||||
@@ -98,7 +99,7 @@ export class Amqp implements INodeType {
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const credentials = this.getCredentials('amqp');
|
||||
if (!credentials) {
|
||||
throw new Error('Credentials are mandatory!');
|
||||
throw new NodeOperationError(this.getNode(), 'Credentials are mandatory!');
|
||||
}
|
||||
|
||||
const sink = this.getNodeParameter('sink', 0, '') as string;
|
||||
@@ -116,7 +117,7 @@ export class Amqp implements INodeType {
|
||||
}
|
||||
|
||||
if (sink === '') {
|
||||
throw new Error('Queue or Topic required!');
|
||||
throw new NodeOperationError(this.getNode(), 'Queue or Topic required!');
|
||||
}
|
||||
|
||||
const container = create_container();
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
ITriggerResponse,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
|
||||
@@ -133,7 +134,7 @@ export class AmqpTrigger implements INodeType {
|
||||
|
||||
const credentials = this.getCredentials('amqp');
|
||||
if (!credentials) {
|
||||
throw new Error('Credentials are mandatory!');
|
||||
throw new NodeOperationError(this.getNode(), 'Credentials are mandatory!');
|
||||
}
|
||||
|
||||
const sink = this.getNodeParameter('sink', '') as string;
|
||||
@@ -146,7 +147,7 @@ export class AmqpTrigger implements INodeType {
|
||||
const containerReconnectLimit = options.reconnectLimit as number || 50;
|
||||
|
||||
if (sink === '') {
|
||||
throw new Error('Queue or Topic required!');
|
||||
throw new NodeOperationError(this.getNode(), 'Queue or Topic required!');
|
||||
}
|
||||
|
||||
let durable = false;
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -466,7 +467,7 @@ export class ApiTemplateIo implements INodeType {
|
||||
if (overrideJson !== '') {
|
||||
const data = validateJSON(overrideJson);
|
||||
if (data === undefined) {
|
||||
throw new Error('A valid JSON must be provided.');
|
||||
throw new NodeOperationError(this.getNode(), 'A valid JSON must be provided.');
|
||||
}
|
||||
body.overrides = data;
|
||||
}
|
||||
@@ -523,14 +524,14 @@ export class ApiTemplateIo implements INodeType {
|
||||
if (jsonParameters === false) {
|
||||
const properties = (this.getNodeParameter('propertiesUi', i) as IDataObject || {}).propertyValues as IDataObject[] || [];
|
||||
if (properties.length === 0) {
|
||||
throw new Error('The parameter properties cannot be empty');
|
||||
throw new NodeOperationError(this.getNode(), 'The parameter properties cannot be empty');
|
||||
}
|
||||
data = properties.reduce((obj, value) => Object.assign(obj, { [`${value.key}`]: value.value }), {});
|
||||
} else {
|
||||
const propertiesJson = this.getNodeParameter('propertiesJson', i) as string;
|
||||
data = validateJSON(propertiesJson);
|
||||
if (data === undefined) {
|
||||
throw new Error('A valid JSON must be provided.');
|
||||
throw new NodeOperationError(this.getNode(), 'A valid JSON must be provided.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
IExecuteFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function apiTemplateIoApiRequest(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
@@ -42,14 +43,11 @@ export async function apiTemplateIoApiRequest(
|
||||
try {
|
||||
const response = await this.helpers.request!(options);
|
||||
if (response.status === 'error') {
|
||||
throw new Error(response.message);
|
||||
throw new NodeApiError(this.getNode(), response.message);
|
||||
}
|
||||
return response;
|
||||
} catch (error) {
|
||||
if (error?.response?.body?.message) {
|
||||
throw new Error(`APITemplate.io error response [${error.statusCode}]: ${error.response.body.message}`);
|
||||
}
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ import {
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -1639,7 +1641,7 @@ export class Asana implements INodeType {
|
||||
const responseData = await asanaApiRequest.call(this, 'GET', endpoint, {});
|
||||
|
||||
if (responseData.data === undefined) {
|
||||
throw new Error('No data got returned');
|
||||
throw new NodeApiError(this.getNode(), responseData, { message: 'No data got returned' });
|
||||
}
|
||||
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
@@ -1674,7 +1676,7 @@ export class Asana implements INodeType {
|
||||
const responseData = await asanaApiRequest.call(this, 'GET', endpoint, {});
|
||||
|
||||
if (responseData.data === undefined) {
|
||||
throw new Error('No data got returned');
|
||||
throw new NodeApiError(this.getNode(), responseData, { message: 'No data got returned' });
|
||||
}
|
||||
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
@@ -1711,7 +1713,7 @@ export class Asana implements INodeType {
|
||||
// to retrieve the teams from an organization just work with workspaces that are an organization
|
||||
|
||||
if (workspace.is_organization === false) {
|
||||
throw Error('To filter by team, the workspace selected has to be an organization');
|
||||
throw new NodeOperationError(this.getNode(), 'To filter by team, the workspace selected has to be an organization');
|
||||
}
|
||||
|
||||
const endpoint = `/organizations/${workspaceId}/teams`;
|
||||
@@ -1750,15 +1752,15 @@ export class Asana implements INodeType {
|
||||
let taskData;
|
||||
try {
|
||||
taskData = await asanaApiRequest.call(this, 'GET', `/tasks/${taskId}`, {});
|
||||
} catch (e) {
|
||||
throw new Error(`Could not find task with id "${taskId}" so tags could not be loaded.`);
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error, { message: `Could not find task with id "${taskId}" so tags could not be loaded.` });
|
||||
}
|
||||
|
||||
const workspace = taskData.data.workspace.gid;
|
||||
const responseData = await asanaApiRequest.call(this, 'GET', endpoint, {}, { workspace });
|
||||
|
||||
if (responseData.data === undefined) {
|
||||
throw new Error('No data got returned');
|
||||
throw new NodeApiError(this.getNode(), responseData, { message: 'No data got returned' });
|
||||
}
|
||||
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
@@ -1790,7 +1792,7 @@ export class Asana implements INodeType {
|
||||
const responseData = await asanaApiRequest.call(this, 'GET', endpoint, {});
|
||||
|
||||
if (responseData.data === undefined) {
|
||||
throw new Error('No data got returned');
|
||||
throw new NodeApiError(this.getNode(), responseData, { message: 'No data got returned' });
|
||||
}
|
||||
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IWebhookResponseData,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -155,7 +156,7 @@ export class AsanaTrigger implements INodeType {
|
||||
const webhookUrl = this.getNodeWebhookUrl('default') as string;
|
||||
|
||||
if (webhookUrl.includes('%20')) {
|
||||
throw new Error('The name of the Asana Trigger Node is not allowed to contain any spaces!');
|
||||
throw new NodeOperationError(this.getNode(), 'The name of the Asana Trigger Node is not allowed to contain any spaces!');
|
||||
}
|
||||
|
||||
const resource = this.getNodeParameter('resource') as string;
|
||||
@@ -189,7 +190,7 @@ export class AsanaTrigger implements INodeType {
|
||||
|
||||
try {
|
||||
await asanaApiRequest.call(this, 'DELETE', endpoint, body);
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ import {
|
||||
import {
|
||||
IDataObject,
|
||||
INodePropertyOptions,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -43,7 +45,7 @@ export async function asanaApiRequest(this: IHookFunctions | IExecuteFunctions |
|
||||
const credentials = this.getCredentials('asanaApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
options.headers!['Authorization'] = `Bearer ${credentials.accessToken}`;
|
||||
@@ -54,25 +56,7 @@ export async function asanaApiRequest(this: IHookFunctions | IExecuteFunctions |
|
||||
return await this.helpers.requestOAuth2.call(this, 'asanaOAuth2Api', options);
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.statusCode === 401) {
|
||||
// Return a clear error
|
||||
throw new Error('The Asana credentials are not valid!');
|
||||
}
|
||||
|
||||
if (error.statusCode === 403) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (error.response && error.response.body && error.response.body.errors) {
|
||||
// Try to return the error prettier
|
||||
const errorMessages = error.response.body.errors.map((errorData: { message: string }) => {
|
||||
return errorData.message;
|
||||
});
|
||||
throw new Error(`Asana error response [${error.statusCode}]: ${errorMessages.join(' | ')}`);
|
||||
}
|
||||
|
||||
// If that data does not exist for some reason return the actual error
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IDataObject, NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function automizyApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, path: string, body: any = {}, qs: IDataObject = {}, option = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
@@ -40,14 +40,7 @@ export async function automizyApiRequest(this: IExecuteFunctions | IExecuteSingl
|
||||
//@ts-ignore
|
||||
return await this.helpers.request.call(this, options);
|
||||
} catch (error) {
|
||||
if (error.response && error.response.body) {
|
||||
|
||||
throw new Error(
|
||||
`Automizy error response [${error.statusCode}]: ${error.response.body.title}`,
|
||||
);
|
||||
}
|
||||
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
IDataObject,
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function autopilotApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
@@ -42,11 +43,7 @@ export async function autopilotApiRequest(this: IExecuteFunctions | IWebhookFunc
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
if (error.response) {
|
||||
const errorMessage = error.response.body.message || error.response.body.description || error.message;
|
||||
throw new Error(`Autopilot error response [${error.statusCode}]: ${errorMessage}`);
|
||||
}
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ import {
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { awsApiRequestREST } from './GenericFunctions';
|
||||
@@ -130,13 +132,7 @@ export class AwsLambda implements INodeType {
|
||||
loadOptions: {
|
||||
async getFunctions(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
|
||||
let data;
|
||||
try {
|
||||
data = await awsApiRequestREST.call(this, 'lambda', 'GET', '/2015-03-31/functions/');
|
||||
} catch (err) {
|
||||
throw new Error(`AWS Error: ${err}`);
|
||||
}
|
||||
const data = await awsApiRequestREST.call(this, 'lambda', 'GET', '/2015-03-31/functions/');
|
||||
|
||||
for (const func of data.Functions!) {
|
||||
returnData.push({
|
||||
@@ -162,22 +158,17 @@ export class AwsLambda implements INodeType {
|
||||
Qualifier: this.getNodeParameter('qualifier', i) as string,
|
||||
};
|
||||
|
||||
let responseData;
|
||||
try {
|
||||
responseData = await awsApiRequestREST.call(
|
||||
this,
|
||||
'lambda',
|
||||
'POST',
|
||||
`/2015-03-31/functions/${params.FunctionName}/invocations?Qualifier=${params.Qualifier}`,
|
||||
params.Payload,
|
||||
{
|
||||
'X-Amz-Invocation-Type': params.InvocationType,
|
||||
'Content-Type': 'application/x-amz-json-1.0',
|
||||
},
|
||||
);
|
||||
} catch (err) {
|
||||
throw new Error(`AWS Error: ${err}`);
|
||||
}
|
||||
const responseData = await awsApiRequestREST.call(
|
||||
this,
|
||||
'lambda',
|
||||
'POST',
|
||||
`/2015-03-31/functions/${params.FunctionName}/invocations?Qualifier=${params.Qualifier}`,
|
||||
params.Payload,
|
||||
{
|
||||
'X-Amz-Invocation-Type': params.InvocationType,
|
||||
'Content-Type': 'application/x-amz-json-1.0',
|
||||
},
|
||||
);
|
||||
|
||||
if (responseData !== null && responseData.errorMessage !== undefined) {
|
||||
let errorMessage = responseData.errorMessage;
|
||||
@@ -186,7 +177,7 @@ export class AwsLambda implements INodeType {
|
||||
errorMessage += `\n\nStack trace:\n${responseData.stackTrace}`;
|
||||
}
|
||||
|
||||
throw new Error(errorMessage);
|
||||
throw new NodeApiError(this.getNode(), responseData);
|
||||
} else {
|
||||
returnData.push({
|
||||
result: responseData,
|
||||
|
||||
@@ -6,6 +6,8 @@ import {
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { awsApiRequestSOAP } from './GenericFunctions';
|
||||
@@ -107,12 +109,7 @@ export class AwsSns implements INodeType {
|
||||
// select them easily
|
||||
async getTopics(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
let data;
|
||||
try {
|
||||
data = await awsApiRequestSOAP.call(this, 'sns', 'GET', '/?Action=ListTopics');
|
||||
} catch (err) {
|
||||
throw new Error(`AWS Error: ${err}`);
|
||||
}
|
||||
const data = await awsApiRequestSOAP.call(this, 'sns', 'GET', '/?Action=ListTopics');
|
||||
|
||||
let topics = data.ListTopicsResponse.ListTopicsResult.Topics.member;
|
||||
|
||||
@@ -149,12 +146,8 @@ export class AwsSns implements INodeType {
|
||||
'Message=' + this.getNodeParameter('message', i) as string,
|
||||
];
|
||||
|
||||
let responseData;
|
||||
try {
|
||||
responseData = await awsApiRequestSOAP.call(this, 'sns', 'GET', '/?Action=Publish&' + params.join('&'));
|
||||
} catch (err) {
|
||||
throw new Error(`AWS Error: ${err}`);
|
||||
}
|
||||
|
||||
const responseData = await awsApiRequestSOAP.call(this, 'sns', 'GET', '/?Action=Publish&' + params.join('&'));
|
||||
returnData.push({MessageId: responseData.PublishResponse.PublishResult.MessageId} as IDataObject);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ import {
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IWebhookResponseData,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -68,12 +70,7 @@ export class AwsSnsTrigger implements INodeType {
|
||||
// select them easily
|
||||
async getTopics(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
let data;
|
||||
try {
|
||||
data = await awsApiRequestSOAP.call(this, 'sns', 'GET', '/?Action=ListTopics');
|
||||
} catch (err) {
|
||||
throw new Error(`AWS Error: ${err}`);
|
||||
}
|
||||
const data = await awsApiRequestSOAP.call(this, 'sns', 'GET', '/?Action=ListTopics');
|
||||
|
||||
let topics = data.ListTopicsResponse.ListTopicsResult.Topics.member;
|
||||
|
||||
@@ -134,7 +131,7 @@ export class AwsSnsTrigger implements INodeType {
|
||||
const topic = this.getNodeParameter('topic') as string;
|
||||
|
||||
if (webhookUrl.includes('%20')) {
|
||||
throw new Error('The name of the SNS Trigger Node is not allowed to contain any spaces!');
|
||||
throw new NodeOperationError(this.getNode(), 'The name of the SNS Trigger Node is not allowed to contain any spaces!');
|
||||
}
|
||||
|
||||
const params = [
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
ICredentialDataDecryptedObject,
|
||||
ICredentialDataDecryptedObject, NodeApiError, NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
function getEndpointForService(service: string, credentials: ICredentialDataDecryptedObject): string {
|
||||
@@ -40,7 +40,7 @@ function getEndpointForService(service: string, credentials: ICredentialDataDecr
|
||||
export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('aws');
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
// Concatenate path and instantiate URL object so it parses correctly query strings
|
||||
@@ -61,17 +61,7 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
const errorMessage = (error.response && error.response.body.message) || (error.response && error.response.body.Message) || error.message;
|
||||
|
||||
if (error.statusCode === 403) {
|
||||
if (errorMessage === 'The security token included in the request is invalid.') {
|
||||
throw new Error('The AWS credentials are not valid!');
|
||||
} else if (errorMessage.startsWith('The request signature we calculated does not match the signature you provided')) {
|
||||
throw new Error('The AWS credentials are not valid!');
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`AWS error response [${error.statusCode}]: ${errorMessage}`);
|
||||
throw new NodeApiError(this.getNode(), error); // no XML parsing needed
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +69,7 @@ export async function awsApiRequestREST(this: IHookFunctions | IExecuteFunctions
|
||||
const response = await awsApiRequest.call(this, service, method, path, body, headers);
|
||||
try {
|
||||
return JSON.parse(response);
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -95,7 +85,7 @@ export async function awsApiRequestSOAP(this: IHookFunctions | IExecuteFunctions
|
||||
resolve(data);
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { URL } from 'url';
|
||||
import { sign } from 'aws4';
|
||||
import { OptionsWithUri } from 'request';
|
||||
import { parseString } from 'xml2js';
|
||||
import { parseString as parseXml } from 'xml2js';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
ICredentialDataDecryptedObject,
|
||||
ICredentialDataDecryptedObject, NodeApiError, NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
function getEndpointForService(service: string, credentials: ICredentialDataDecryptedObject): string {
|
||||
@@ -31,7 +31,7 @@ function getEndpointForService(service: string, credentials: ICredentialDataDecr
|
||||
export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('aws');
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
// Concatenate path and instantiate URL object so it parses correctly query strings
|
||||
@@ -52,17 +52,7 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
const errorMessage = (error.response && error.response.body.message) || (error.response && error.response.body.Message) || error.message;
|
||||
|
||||
if (error.statusCode === 403) {
|
||||
if (errorMessage === 'The security token included in the request is invalid.') {
|
||||
throw new Error('The AWS credentials are not valid!');
|
||||
} else if (errorMessage.startsWith('The request signature we calculated does not match the signature you provided')) {
|
||||
throw new Error('The AWS credentials are not valid!');
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`AWS error response [${error.statusCode}]: ${errorMessage}`);
|
||||
throw new NodeApiError(this.getNode(), error, { parseXml: true });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +60,7 @@ export async function awsApiRequestREST(this: IHookFunctions | IExecuteFunctions
|
||||
const response = await awsApiRequest.call(this, service, method, path, body, headers);
|
||||
try {
|
||||
return JSON.parse(response);
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -79,14 +69,14 @@ export async function awsApiRequestSOAP(this: IHookFunctions | IExecuteFunctions
|
||||
const response = await awsApiRequest.call(this, service, method, path, body, headers);
|
||||
try {
|
||||
return await new Promise((resolve, reject) => {
|
||||
parseString(response, { explicitArray: false }, (err, data) => {
|
||||
parseXml(response, { explicitArray: false }, (err, data) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
resolve(data);
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -459,11 +461,11 @@ export class AwsRekognition implements INodeType {
|
||||
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string;
|
||||
|
||||
if (items[i].binary === undefined) {
|
||||
throw new Error('No binary data exists on item!');
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!');
|
||||
}
|
||||
|
||||
if ((items[i].binary as IBinaryKeyData)[binaryPropertyName] === undefined) {
|
||||
throw new Error(`No binary data property "${binaryPropertyName}" does not exists on item!`);
|
||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`);
|
||||
}
|
||||
|
||||
const binaryPropertyData = (items[i].binary as IBinaryKeyData)[binaryPropertyName];
|
||||
@@ -494,7 +496,9 @@ export class AwsRekognition implements INodeType {
|
||||
body.Image.S3Object.Version = additionalFields.version as string;
|
||||
}
|
||||
}
|
||||
|
||||
responseData = await awsApiRequestREST.call(this, 'rekognition', 'POST', '', JSON.stringify(body), {}, { 'X-Amz-Target': action, 'Content-Type': 'application/x-amz-json-1.1' });
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ import {
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -36,7 +38,7 @@ import {
|
||||
export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string | Buffer | IDataObject, query: IDataObject = {}, headers?: object, option: IDataObject = {}, region?: string): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('aws');
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const endpoint = new URL(((credentials.rekognitionEndpoint as string || '').replace('{region}', credentials.region as string) || `https://${service}.${credentials.region}.amazonaws.com`) + path);
|
||||
@@ -59,17 +61,7 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
const errorMessage = (error.response && error.response.body.message) || (error.response && error.response.body.Message) || error.message;
|
||||
|
||||
if (error.statusCode === 403) {
|
||||
if (errorMessage === 'The security token included in the request is invalid.') {
|
||||
throw new Error('The AWS credentials are not valid!');
|
||||
} else if (errorMessage.startsWith('The request signature we calculated does not match the signature you provided')) {
|
||||
throw new Error('The AWS credentials are not valid!');
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`AWS error response [${error.statusCode}]: ${errorMessage}`);
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +69,7 @@ export async function awsApiRequestREST(this: IHookFunctions | IExecuteFunctions
|
||||
const response = await awsApiRequest.call(this, service, method, path, body, query, headers, options, region);
|
||||
try {
|
||||
return JSON.parse(response);
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -93,8 +85,8 @@ export async function awsApiRequestSOAP(this: IHookFunctions | IExecuteFunctions
|
||||
resolve(data);
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
return e;
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -422,7 +423,7 @@ export class AwsS3 implements INodeType {
|
||||
const fileName = fileKey.split('/')[fileKey.split('/').length - 1];
|
||||
|
||||
if (fileKey.substring(fileKey.length - 1) === '/') {
|
||||
throw new Error('Downloding a whole directory is not yet supported, please provide a file key');
|
||||
throw new NodeOperationError(this.getNode(), 'Downloding a whole directory is not yet supported, please provide a file key');
|
||||
}
|
||||
|
||||
let region = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { location: '' });
|
||||
@@ -588,11 +589,11 @@ export class AwsS3 implements INodeType {
|
||||
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string;
|
||||
|
||||
if (items[i].binary === undefined) {
|
||||
throw new Error('No binary data exists on item!');
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!');
|
||||
}
|
||||
|
||||
if ((items[i].binary as IBinaryKeyData)[binaryPropertyName] === undefined) {
|
||||
throw new Error(`No binary data property "${binaryPropertyName}" does not exists on item!`);
|
||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`);
|
||||
}
|
||||
|
||||
const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName];
|
||||
|
||||
@@ -26,20 +26,20 @@ import {
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IDataObject, NodeApiError, NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string | Buffer, query: IDataObject = {}, headers?: object, option: IDataObject = {}, region?: string): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('aws');
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const endpoint = new URL(((credentials.s3Endpoint as string || '').replace('{region}', credentials.region as string) || `https://${service}.${credentials.region}.amazonaws.com`) + path);
|
||||
|
||||
// Sign AWS API request with the user credentials
|
||||
const signOpts = {headers: headers || {}, host: endpoint.host, method, path: `${endpoint.pathname}?${queryToString(query).replace(/\+/g, '%2B')}`, body};
|
||||
|
||||
|
||||
|
||||
sign(signOpts, { accessKeyId: `${credentials.accessKeyId}`.trim(), secretAccessKey: `${credentials.secretAccessKey}`.trim()});
|
||||
|
||||
@@ -57,17 +57,7 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
const errorMessage = (error.response && error.response.body.message) || (error.response && error.response.body.Message) || error.message;
|
||||
|
||||
if (error.statusCode === 403) {
|
||||
if (errorMessage === 'The security token included in the request is invalid.') {
|
||||
throw new Error('The AWS credentials are not valid!');
|
||||
} else if (errorMessage.startsWith('The request signature we calculated does not match the signature you provided')) {
|
||||
throw new Error('The AWS credentials are not valid!');
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`AWS error response [${error.statusCode}]: ${errorMessage}`);
|
||||
throw new NodeApiError(this.getNode(), error, { parseXml: true });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +65,7 @@ export async function awsApiRequestREST(this: IHookFunctions | IExecuteFunctions
|
||||
const response = await awsApiRequest.call(this, service, method, path, body, query, headers, options, region);
|
||||
try {
|
||||
return JSON.parse(response);
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -91,8 +81,8 @@ export async function awsApiRequestSOAP(this: IHookFunctions | IExecuteFunctions
|
||||
resolve(data);
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
return e;
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -1098,7 +1099,7 @@ export class AwsSes implements INodeType {
|
||||
if (toAddresses.length) {
|
||||
setParameter(params, 'Destination.ToAddresses.member', toAddresses);
|
||||
} else {
|
||||
throw new Error('At least one "To Address" has to be added!');
|
||||
throw new NodeOperationError(this.getNode(), 'At least one "To Address" has to be added!');
|
||||
}
|
||||
|
||||
if (additionalFields.configurationSetName) {
|
||||
@@ -1151,7 +1152,7 @@ export class AwsSes implements INodeType {
|
||||
if (toAddresses.length) {
|
||||
setParameter(params, 'Destination.ToAddresses.member', toAddresses);
|
||||
} else {
|
||||
throw new Error('At least one "To Address" has to be added!');
|
||||
throw new NodeOperationError(this.getNode(), 'At least one "To Address" has to be added!');
|
||||
}
|
||||
|
||||
if (additionalFields.configurationSetName) {
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IDataObject, NodeApiError, NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -32,7 +32,7 @@ import {
|
||||
export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('aws');
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const endpoint = new URL(((credentials.sesEndpoint as string || '').replace('{region}', credentials.region as string) || `https://${service}.${credentials.region}.amazonaws.com`) + path);
|
||||
@@ -52,17 +52,7 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
const errorMessage = (error.response && error.response.body.message) || (error.response && error.response.body.Message) || error.message;
|
||||
|
||||
if (error.statusCode === 403) {
|
||||
if (errorMessage === 'The security token included in the request is invalid.') {
|
||||
throw new Error('The AWS credentials are not valid!');
|
||||
} else if (errorMessage.startsWith('The request signature we calculated does not match the signature you provided')) {
|
||||
throw new Error('The AWS credentials are not valid!');
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`AWS error response [${error.statusCode}]: ${errorMessage}`);
|
||||
throw new NodeApiError(this.getNode(), error, { parseXml: true });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +60,7 @@ export async function awsApiRequestREST(this: IHookFunctions | IExecuteFunctions
|
||||
const response = await awsApiRequest.call(this, service, method, path, body, headers);
|
||||
try {
|
||||
return JSON.parse(response);
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -86,7 +76,7 @@ export async function awsApiRequestSOAP(this: IHookFunctions | IExecuteFunctions
|
||||
resolve(data);
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ import {
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -270,8 +272,8 @@ export class AwsSqs implements INodeType {
|
||||
try {
|
||||
// loads first 1000 queues from SQS
|
||||
data = await awsApiRequestSOAP.call(this, 'sqs', 'GET', `?Action=ListQueues`);
|
||||
} catch (err) {
|
||||
throw new Error(`AWS Error: ${err}`);
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
|
||||
let queues = data.ListQueuesResponse.ListQueuesResult.QueueUrl;
|
||||
@@ -349,11 +351,11 @@ export class AwsSqs implements INodeType {
|
||||
const item = items[i];
|
||||
|
||||
if (item.binary === undefined) {
|
||||
throw new Error('No binary data set. So message attribute cannot be added!');
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data set. So message attribute cannot be added!');
|
||||
}
|
||||
|
||||
if (item.binary[dataPropertyName] === undefined) {
|
||||
throw new Error(`The binary property "${dataPropertyName}" does not exist. So message attribute cannot be added!`);
|
||||
throw new NodeOperationError(this.getNode(), `The binary property "${dataPropertyName}" does not exist. So message attribute cannot be added!`);
|
||||
}
|
||||
|
||||
const binaryData = item.binary[dataPropertyName].data;
|
||||
@@ -374,8 +376,8 @@ export class AwsSqs implements INodeType {
|
||||
let responseData;
|
||||
try {
|
||||
responseData = await awsApiRequestSOAP.call(this, 'sqs', 'GET', `${queuePath}/?Action=${operation}&` + params.join('&'));
|
||||
} catch (err) {
|
||||
throw new Error(`AWS Error: ${err}`);
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
|
||||
const result = responseData.SendMessageResponse.SendMessageResult;
|
||||
|
||||
@@ -11,6 +11,8 @@ import {
|
||||
IDataObject,
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -22,7 +24,7 @@ export async function bannerbearApiRequest(this: IExecuteFunctions | IWebhookFun
|
||||
const credentials = this.getCredentials('bannerbearApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
@@ -46,12 +48,7 @@ export async function bannerbearApiRequest(this: IExecuteFunctions | IWebhookFun
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
if (error.response && error.response.body && error.response.body.message) {
|
||||
// Try to return the error prettier
|
||||
//@ts-ignore
|
||||
throw new Error(`Bannerbear error response [${error.statusCode}]: ${error.response.body.message}`);
|
||||
}
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
IDataObject,
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -18,7 +19,7 @@ export async function createDatapoint(this: IExecuteFunctions | IWebhookFunction
|
||||
const credentials = this.getCredentials('beeminderApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const endpoint = `/users/${credentials.user}/goals/${data.goalName}/datapoints.json`;
|
||||
@@ -30,7 +31,7 @@ export async function getAllDatapoints(this: IExecuteFunctions | IHookFunctions
|
||||
const credentials = this.getCredentials('beeminderApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const endpoint = `/users/${credentials.user}/goals/${data.goalName}/datapoints.json`;
|
||||
@@ -46,7 +47,7 @@ export async function updateDatapoint(this: IExecuteFunctions | IWebhookFunction
|
||||
const credentials = this.getCredentials('beeminderApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const endpoint = `/users/${credentials.user}/goals/${data.goalName}/datapoints/${data.datapointId}.json`;
|
||||
@@ -58,7 +59,7 @@ export async function deleteDatapoint(this: IExecuteFunctions | IWebhookFunction
|
||||
const credentials = this.getCredentials('beeminderApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const endpoint = `/users/${credentials.user}/goals/${data.goalName}/datapoints/${data.datapointId}.json`;
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -308,7 +309,7 @@ export class Beeminder implements INodeType {
|
||||
const credentials = this.getCredentials('beeminderApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const endpoint = `/users/${credentials.user}/goals.json`;
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
IDataObject,
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
const BEEMINDER_URI = 'https://www.beeminder.com/api/v1';
|
||||
@@ -40,10 +41,7 @@ export async function beeminderApiRequest(this: IExecuteFunctions | IWebhookFunc
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
if (error?.message) {
|
||||
throw new Error(`Beeminder error response [${error.statusCode}]: ${error.message}`);
|
||||
}
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -280,7 +280,7 @@ export class BitbucketTrigger implements INodeType {
|
||||
}
|
||||
try {
|
||||
await bitbucketApiRequest.call(this, 'GET', endpoint);
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -5,12 +5,12 @@ import {
|
||||
IHookFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IDataObject } from 'n8n-workflow';
|
||||
import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow';
|
||||
|
||||
export async function bitbucketApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('bitbucketApi');
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
let options: OptionsWithUri = {
|
||||
method,
|
||||
@@ -30,8 +30,8 @@ export async function bitbucketApiRequest(this: IHookFunctions | IExecuteFunctio
|
||||
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (err) {
|
||||
throw new Error('Bitbucket Error: ' + err.message);
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IDataObject, NodeApiError, NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function bitlyApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
@@ -32,7 +32,7 @@ export async function bitlyApiRequest(this: IHookFunctions | IExecuteFunctions |
|
||||
if (authenticationMethod === 'accessToken') {
|
||||
const credentials = this.getCredentials('bitlyApi');
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
options.headers = { Authorization: `Bearer ${credentials.accessToken}`};
|
||||
|
||||
@@ -42,15 +42,7 @@ export async function bitlyApiRequest(this: IHookFunctions | IExecuteFunctions |
|
||||
return await this.helpers.requestOAuth2!.call(this, 'bitlyOAuth2Api', options, { tokenType: 'Bearer' });
|
||||
}
|
||||
} catch(error) {
|
||||
|
||||
if (error.response && error.response.body && error.response.body.message) {
|
||||
// Try to return the error prettier
|
||||
const errorBody = error.response.body;
|
||||
throw new Error(`Bitly error response [${error.statusCode}]: ${errorBody.message}`);
|
||||
}
|
||||
|
||||
// Expected error data did not get returned so throw the actual error
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -177,7 +178,7 @@ export class Bitwarden implements INodeType {
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as CollectionUpdateFields;
|
||||
|
||||
if (isEmpty(updateFields)) {
|
||||
throw new Error(`Please enter at least one field to update for the ${resource}.`);
|
||||
throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`);
|
||||
}
|
||||
|
||||
const { groups, externalId } = updateFields;
|
||||
@@ -308,7 +309,7 @@ export class Bitwarden implements INodeType {
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as GroupUpdateFields;
|
||||
|
||||
if (isEmpty(updateFields)) {
|
||||
throw new Error(`Please enter at least one field to update for the ${resource}.`);
|
||||
throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`);
|
||||
}
|
||||
|
||||
// set defaults for `name` and `accessAll`, required by Bitwarden but optional in n8n
|
||||
@@ -452,7 +453,7 @@ export class Bitwarden implements INodeType {
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as MemberUpdateFields;
|
||||
|
||||
if (isEmpty(updateFields)) {
|
||||
throw new Error(`Please enter at least one field to update for the ${resource}.`);
|
||||
throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`);
|
||||
}
|
||||
|
||||
const { accessAll, collections, externalId, type } = updateFields;
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
IDataObject,
|
||||
ILoadOptionsFunctions,
|
||||
INodePropertyOptions,
|
||||
NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -48,17 +49,7 @@ export async function bitwardenApiRequest(
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
|
||||
if (error.statusCode === 404) {
|
||||
throw new Error('Bitwarden error response [404]: Not found');
|
||||
}
|
||||
|
||||
if (error?.response?.body?.Message) {
|
||||
const message = error?.response?.body?.Message;
|
||||
throw new Error(`Bitwarden error response [${error.statusCode}]: ${message}`);
|
||||
}
|
||||
//TODO handle Errors array
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +84,7 @@ export async function getAccessToken(
|
||||
const { access_token } = await this.helpers.request!(options);
|
||||
return access_token;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -217,11 +218,11 @@ export class Box implements INodeType {
|
||||
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string;
|
||||
|
||||
if (items[i].binary === undefined) {
|
||||
throw new Error('No binary data exists on item!');
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!');
|
||||
}
|
||||
//@ts-ignore
|
||||
if (items[i].binary[binaryPropertyName] === undefined) {
|
||||
throw new Error(`No binary data property "${binaryPropertyName}" does not exists on item!`);
|
||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`);
|
||||
}
|
||||
|
||||
const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName];
|
||||
@@ -248,7 +249,7 @@ export class Box implements INodeType {
|
||||
const content = this.getNodeParameter('fileContent', i) as string;
|
||||
|
||||
if (fileName === '') {
|
||||
throw new Error('File name must be set!');
|
||||
throw new NodeOperationError(this.getNode(), 'File name must be set!');
|
||||
}
|
||||
|
||||
attributes['name'] = fileName;
|
||||
|
||||
@@ -327,7 +327,7 @@ export class BoxTrigger implements INodeType {
|
||||
|
||||
try {
|
||||
await boxApiRequest.call(this, 'DELETE', endpoint);
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
import {
|
||||
IDataObject,
|
||||
IOAuth2Options,
|
||||
NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function boxApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
@@ -41,22 +42,7 @@ export async function boxApiRequest(this: IExecuteFunctions | IExecuteSingleFunc
|
||||
return await this.helpers.requestOAuth2.call(this, 'boxOAuth2Api', options, oAuth2Options);
|
||||
|
||||
} catch (error) {
|
||||
|
||||
let errorMessage;
|
||||
|
||||
if (error.response && error.response.body) {
|
||||
|
||||
if (error.response.body.context_info && error.response.body.context_info.errors) {
|
||||
const errors = error.response.body.context_info.errors;
|
||||
errorMessage = errors.map((e: IDataObject) => e.message);
|
||||
errorMessage = errorMessage.join('|');
|
||||
} else if (error.response.body.message) {
|
||||
errorMessage = error.response.body.message;
|
||||
}
|
||||
|
||||
throw new Error(`Box error response [${error.statusCode}]: ${errorMessage}`);
|
||||
}
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@ import {
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IDataObject, NodeApiError, NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function brandfetchApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
try {
|
||||
const credentials = this.getCredentials('brandfetchApi');
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
let options: OptionsWithUri = {
|
||||
headers: {
|
||||
@@ -46,20 +46,12 @@ export async function brandfetchApiRequest(this: IHookFunctions | IExecuteFuncti
|
||||
const response = await this.helpers.request!(options);
|
||||
|
||||
if (response.statusCode && response.statusCode !== 200) {
|
||||
throw new Error(`Brandfetch error response [${response.statusCode}]: ${response.response}`);
|
||||
throw new NodeApiError(this.getNode(), response);
|
||||
}
|
||||
|
||||
return response;
|
||||
|
||||
} catch (error) {
|
||||
|
||||
if (error.response && error.response.body && error.response.body.message) {
|
||||
// Try to return the error prettier
|
||||
const errorBody = error.response.body;
|
||||
throw new Error(`Brandfetch error response [${error.statusCode}]: ${errorBody.message}`);
|
||||
}
|
||||
|
||||
// Expected error data did not get returned so throw the actual error
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -153,7 +154,7 @@ export class Bubble implements INodeType {
|
||||
const filter = options.filtersJson as string;
|
||||
const data = validateJSON(filter);
|
||||
if (data === undefined) {
|
||||
throw new Error('Filters must be a valid JSON');
|
||||
throw new NodeOperationError(this.getNode(), 'Filters must be a valid JSON');
|
||||
}
|
||||
qs.constraints = JSON.stringify(data);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
import {
|
||||
IDataObject,
|
||||
ILoadOptionsFunctions,
|
||||
NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -57,11 +58,7 @@ export async function bubbleApiRequest(
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
if (error?.response?.body?.body?.message) {
|
||||
const errorMessage = error.response.body.body.message;
|
||||
throw new Error(`Bubble.io error response [${error.statusCode}]: ${errorMessage}`);
|
||||
}
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ export class CalendlyTrigger implements INodeType {
|
||||
|
||||
try {
|
||||
await calendlyApiRequest.call(this, 'DELETE', endpoint);
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@ import {
|
||||
import {
|
||||
IDataObject,
|
||||
IHookFunctions,
|
||||
IWebhookFunctions
|
||||
IWebhookFunctions,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function calendlyApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
@@ -16,7 +18,7 @@ export async function calendlyApiRequest(this: IExecuteFunctions | IWebhookFunct
|
||||
const credentials = this.getCredentials('calendlyApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const endpoint = 'https://calendly.com/api/v1';
|
||||
@@ -42,10 +44,6 @@ export async function calendlyApiRequest(this: IExecuteFunctions | IWebhookFunct
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
if (error.response) {
|
||||
const errorMessage = error.response.body.message || error.response.body.description || error.message;
|
||||
throw new Error(`Calendly error response [${error.statusCode}]: ${errorMessage}`);
|
||||
}
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
NodeParameterValue,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
@@ -489,7 +491,7 @@ export class Chargebee implements INodeType {
|
||||
const credentials = this.getCredentials('chargebeeApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const baseUrl = `https://${credentials.accountName}.chargebee.com/api/v2`;
|
||||
@@ -531,7 +533,7 @@ export class Chargebee implements INodeType {
|
||||
|
||||
endpoint = `customers`;
|
||||
} else {
|
||||
throw new Error(`The operation "${operation}" is not known!`);
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`);
|
||||
}
|
||||
|
||||
} else if (resource === 'invoice') {
|
||||
@@ -569,7 +571,7 @@ export class Chargebee implements INodeType {
|
||||
const invoiceId = this.getNodeParameter('invoiceId', i) as string;
|
||||
endpoint = `invoices/${invoiceId.trim()}/pdf`;
|
||||
} else {
|
||||
throw new Error(`The operation "${operation}" is not known!`);
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`);
|
||||
}
|
||||
|
||||
} else if (resource === 'subscription') {
|
||||
@@ -595,10 +597,10 @@ export class Chargebee implements INodeType {
|
||||
|
||||
endpoint = `subscriptions/${subscriptionId.trim()}/delete`;
|
||||
} else {
|
||||
throw new Error(`The operation "${operation}" is not known!`);
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`);
|
||||
}
|
||||
} else {
|
||||
throw new Error(`The resource "${resource}" is not known!`);
|
||||
throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`);
|
||||
}
|
||||
|
||||
const options = {
|
||||
@@ -613,7 +615,13 @@ export class Chargebee implements INodeType {
|
||||
json: true,
|
||||
};
|
||||
|
||||
const responseData = await this.helpers.request!(options);
|
||||
let responseData;
|
||||
|
||||
try {
|
||||
responseData = await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
|
||||
if (resource === 'invoice' && operation === 'list') {
|
||||
responseData.list.forEach((data: IDataObject) => {
|
||||
|
||||
@@ -10,13 +10,13 @@ import {
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IDataObject, NodeApiError, NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function circleciApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('circleCiApi');
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
let options: OptionsWithUri = {
|
||||
headers: {
|
||||
@@ -35,14 +35,9 @@ export async function circleciApiRequest(this: IHookFunctions | IExecuteFunction
|
||||
}
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (err) {
|
||||
if (err.response && err.response.body && err.response.body.message) {
|
||||
// Try to return the error prettier
|
||||
throw new Error(`CircleCI error response [${err.statusCode}]: ${err.response.body.message}`);
|
||||
}
|
||||
|
||||
// If that data does not exist for some reason return the actual error
|
||||
throw err; }
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,14 +9,12 @@ import {
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow';
|
||||
|
||||
export async function clearbitApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, api: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('clearbitApi');
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
let options: OptionsWithUri = {
|
||||
headers: { Authorization: `Bearer ${credentials.apiKey}` },
|
||||
@@ -33,17 +31,6 @@ export async function clearbitApiRequest(this: IHookFunctions | IExecuteFunction
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
if (error.statusCode === 401) {
|
||||
// Return a clear error
|
||||
throw new Error('The Clearbit credentials are not valid!');
|
||||
}
|
||||
|
||||
if (error.response.body && error.response.body.error && error.response.body.error.message) {
|
||||
// Try to return the error prettier
|
||||
throw new Error(`Clearbit Error [${error.statusCode}]: ${error.response.body.error.message}`);
|
||||
}
|
||||
|
||||
// If that data does not exist for some reason return the actual error
|
||||
throw new Error('Clearbit Error: ' + error.message);
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -719,14 +720,14 @@ export class ClickUp implements INodeType {
|
||||
};
|
||||
if (type === 'number' || type === 'currency') {
|
||||
if (!additionalFields.unit) {
|
||||
throw new Error('Unit field must be set');
|
||||
throw new NodeOperationError(this.getNode(), 'Unit field must be set');
|
||||
}
|
||||
}
|
||||
if (type === 'number' || type === 'percentaje'
|
||||
|| type === 'automatic' || type === 'currency') {
|
||||
if (additionalFields.stepsStart === undefined
|
||||
|| !additionalFields.stepsEnd === undefined) {
|
||||
throw new Error('Steps start and steps end fields must be set');
|
||||
throw new NodeOperationError(this.getNode(), 'Steps start and steps end fields must be set');
|
||||
}
|
||||
}
|
||||
if (additionalFields.unit) {
|
||||
@@ -845,7 +846,7 @@ export class ClickUp implements INodeType {
|
||||
if (additionalFields.customFieldsJson) {
|
||||
const customFields = validateJSON(additionalFields.customFieldsJson as string);
|
||||
if (customFields === undefined) {
|
||||
throw new Error('Custom Fields: Invalid JSON');
|
||||
throw new NodeOperationError(this.getNode(), 'Custom Fields: Invalid JSON');
|
||||
}
|
||||
body.custom_fields = customFields;
|
||||
}
|
||||
@@ -1042,7 +1043,7 @@ export class ClickUp implements INodeType {
|
||||
if (jsonParse === true) {
|
||||
body.value = validateJSON(body.value);
|
||||
if (body.value === undefined) {
|
||||
throw new Error('Value is invalid JSON!');
|
||||
throw new NodeOperationError(this.getNode(), 'Value is invalid JSON!');
|
||||
}
|
||||
} else {
|
||||
//@ts-ignore
|
||||
@@ -1213,7 +1214,7 @@ export class ClickUp implements INodeType {
|
||||
if (responseData.data) {
|
||||
responseData = responseData.data;
|
||||
} else {
|
||||
throw new Error('There seems to be nothing to stop.');
|
||||
throw new NodeOperationError(this.getNode(), 'There seems to be nothing to stop.');
|
||||
}
|
||||
}
|
||||
if (operation === 'delete') {
|
||||
@@ -1233,7 +1234,7 @@ export class ClickUp implements INodeType {
|
||||
if (tagsUi) {
|
||||
const tags = (tagsUi as IDataObject).tagsValues as IDataObject[];
|
||||
if (tags === undefined) {
|
||||
throw new Error('At least one tag must be set');
|
||||
throw new NodeOperationError(this.getNode(), 'At least one tag must be set');
|
||||
}
|
||||
body.tags = tags;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,10 @@ import {
|
||||
import {
|
||||
IDataObject,
|
||||
IOAuth2Options,
|
||||
NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
|
||||
export async function clickupApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
const options: OptionsWithUri = {
|
||||
headers: {
|
||||
@@ -34,15 +36,10 @@ export async function clickupApiRequest(this: IHookFunctions | IExecuteFunctions
|
||||
|
||||
const credentials = this.getCredentials('clickUpApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
}
|
||||
|
||||
options.headers!['Authorization'] = credentials.accessToken;
|
||||
options.headers!['Authorization'] = credentials?.accessToken;
|
||||
return await this.helpers.request!(options);
|
||||
|
||||
} else {
|
||||
|
||||
const oAuth2Options: IOAuth2Options = {
|
||||
keepBearer: false,
|
||||
tokenType: 'Bearer',
|
||||
@@ -50,15 +47,9 @@ export async function clickupApiRequest(this: IHookFunctions | IExecuteFunctions
|
||||
// @ts-ignore
|
||||
return await this.helpers.requestOAuth2!.call(this, 'clickUpOAuth2Api', options, oAuth2Options);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
let errorMessage = error;
|
||||
if (error.err) {
|
||||
errorMessage = error.err;
|
||||
}
|
||||
throw new Error('ClickUp Error: ' + errorMessage);
|
||||
} catch(error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export async function clickupApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IDataObject, NodeApiError, NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function clockifyApiRequest(this: ILoadOptionsFunctions | IPollFunctions | IExecuteFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
@@ -17,7 +17,7 @@ export async function clockifyApiRequest(this: ILoadOptionsFunctions | IPollFunc
|
||||
const credentials = this.getCredentials('clockifyApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
|
||||
}
|
||||
const BASE_URL = 'https://api.clockify.me/api/v1';
|
||||
@@ -36,20 +36,9 @@ export async function clockifyApiRequest(this: ILoadOptionsFunctions | IPollFunc
|
||||
};
|
||||
|
||||
try {
|
||||
|
||||
return await this.helpers.request!(options);
|
||||
|
||||
} catch (error) {
|
||||
|
||||
let errorMessage = error.message;
|
||||
|
||||
if (error.response.body && error.response.body.message) {
|
||||
|
||||
errorMessage = `[${error.statusCode}] ${error.response.body.message}`;
|
||||
|
||||
}
|
||||
|
||||
throw new Error('Clockify Error: ' + errorMessage);
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,14 +3,14 @@ import {
|
||||
IExecuteSingleFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IDataObject } from 'n8n-workflow';
|
||||
import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
export async function cockpitApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('cockpitApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials available.');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials available.');
|
||||
}
|
||||
|
||||
let options: OptionsWithUri = {
|
||||
@@ -36,12 +36,7 @@ export async function cockpitApiRequest(this: IExecuteFunctions | IExecuteSingle
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
let errorMessage = error.message;
|
||||
if (error.error) {
|
||||
errorMessage = error.error.message || error.error.error;
|
||||
}
|
||||
|
||||
throw new Error(`Cockpit error [${error.statusCode}]: ` + errorMessage);
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ import {
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
import {
|
||||
codaApiRequest,
|
||||
@@ -338,8 +340,8 @@ export class Coda implements INodeType {
|
||||
responseData = await codaApiRequest.call(this, 'GET', endpoint, {}, qs);
|
||||
responseData = responseData.items;
|
||||
}
|
||||
} catch (err) {
|
||||
throw new Error(`Coda Error: ${err.message}`);
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
|
||||
if (options.rawData === true) {
|
||||
@@ -540,8 +542,8 @@ export class Coda implements INodeType {
|
||||
responseData = await codaApiRequest.call(this, 'GET', endpoint, {}, qs);
|
||||
responseData = responseData.items;
|
||||
}
|
||||
} catch (err) {
|
||||
throw new Error(`Coda Error: ${err.message}`);
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
|
||||
if (options.rawData === true) {
|
||||
|
||||
@@ -4,12 +4,12 @@ import {
|
||||
IExecuteSingleFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IDataObject } from 'n8n-workflow';
|
||||
import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow';
|
||||
|
||||
export async function codaApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('codaApi');
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
let options: OptionsWithUri = {
|
||||
@@ -28,12 +28,7 @@ export async function codaApiRequest(this: IExecuteFunctions | IExecuteSingleFun
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
let errorMessage = error.message;
|
||||
if (error.response.body) {
|
||||
errorMessage = error.response.body.message || error.response.body.Message || error.message;
|
||||
}
|
||||
|
||||
throw new Error('Coda Error: ' + errorMessage);
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IDataObject, NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function coinGeckoApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string,
|
||||
@@ -37,8 +37,7 @@ export async function coinGeckoApiRequest(this: IExecuteFunctions | IExecuteSing
|
||||
return await this.helpers.request.call(this, options);
|
||||
|
||||
} catch (error) {
|
||||
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import * as fflate from 'fflate';
|
||||
@@ -216,11 +217,11 @@ export class Compression implements INodeType {
|
||||
|
||||
for (const [index, binaryPropertyName] of binaryPropertyNames.entries()) {
|
||||
if (items[i].binary === undefined) {
|
||||
throw new Error('No binary data exists on item!');
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!');
|
||||
}
|
||||
//@ts-ignore
|
||||
if (items[i].binary[binaryPropertyName] === undefined) {
|
||||
throw new Error(`No binary data property "${binaryPropertyName}" does not exists on item!`);
|
||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`);
|
||||
}
|
||||
|
||||
const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName];
|
||||
@@ -270,11 +271,11 @@ export class Compression implements INodeType {
|
||||
for (const [index, binaryPropertyName] of binaryPropertyNames.entries()) {
|
||||
|
||||
if (items[i].binary === undefined) {
|
||||
throw new Error('No binary data exists on item!');
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!');
|
||||
}
|
||||
//@ts-ignore
|
||||
if (items[i].binary[binaryPropertyName] === undefined) {
|
||||
throw new Error(`No binary data property "${binaryPropertyName}" does not exists on item!`);
|
||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`);
|
||||
}
|
||||
|
||||
const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName];
|
||||
|
||||
@@ -9,14 +9,14 @@ import {
|
||||
} from 'request';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IDataObject, NodeApiError, NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function contentfulApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
const credentials = this.getCredentials('contentfulApi');
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const source = this.getNodeParameter('source', 0) as string;
|
||||
@@ -39,7 +39,7 @@ export async function contentfulApiRequest(this: IExecuteFunctions | IExecuteSin
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
throw new Error(`Contentful error response [${error.statusCode}]: ${error.error.message}`);
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,9 @@ import {
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IHookFunctions
|
||||
IHookFunctions,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function convertKitApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions,
|
||||
@@ -19,7 +21,7 @@ export async function convertKitApiRequest(this: IExecuteFunctions | IExecuteSin
|
||||
const credentials = this.getCredentials('convertKitApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
let options: OptionsWithUri = {
|
||||
@@ -51,17 +53,8 @@ export async function convertKitApiRequest(this: IExecuteFunctions | IExecuteSin
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
return await this.helpers.request!(options);
|
||||
|
||||
} catch (error) {
|
||||
|
||||
let errorMessage = error;
|
||||
|
||||
if (error.response && error.response.body && error.response.body.message) {
|
||||
errorMessage = error.response.body.message;
|
||||
}
|
||||
|
||||
throw new Error(`ConvertKit error response: ${errorMessage}`);
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ export class CopperTrigger implements INodeType {
|
||||
const endpoint = `/webhooks/${webhookData.webhookId}`;
|
||||
try {
|
||||
await copperApiRequest.call(this, 'GET', endpoint);
|
||||
} catch (err) {
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
import {
|
||||
ICredentialDataDecryptedObject,
|
||||
IDataObject,
|
||||
NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -72,12 +73,7 @@ export async function copperApiRequest(
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
let errorMessage = error.message;
|
||||
if (error.response.body?.message) {
|
||||
errorMessage = error.response.body.message;
|
||||
}
|
||||
|
||||
throw new Error(`Copper error response [${error.statusCode}]: ${errorMessage}`);
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -231,13 +232,13 @@ export class Cortex implements INodeType {
|
||||
const item = items[i];
|
||||
|
||||
if (item.binary === undefined) {
|
||||
throw new Error('No binary data exists on item!');
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!');
|
||||
}
|
||||
|
||||
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string;
|
||||
|
||||
if (item.binary[binaryPropertyName] === undefined) {
|
||||
throw new Error(`No binary data property "${binaryPropertyName}" does not exists on item!`);
|
||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`);
|
||||
}
|
||||
|
||||
const fileBufferData = Buffer.from(item.binary[binaryPropertyName].data, BINARY_ENCODING);
|
||||
@@ -386,13 +387,13 @@ export class Cortex implements INodeType {
|
||||
const item = items[i];
|
||||
|
||||
if (item.binary === undefined) {
|
||||
throw new Error('No binary data exists on item!');
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!');
|
||||
}
|
||||
|
||||
const binaryPropertyName = artifactvalue.binaryProperty as string;
|
||||
|
||||
if (item.binary[binaryPropertyName] === undefined) {
|
||||
throw new Error(`No binary data property '${binaryPropertyName}' does not exists on item!`);
|
||||
throw new NodeOperationError(this.getNode(), `No binary data property '${binaryPropertyName}' does not exists on item!`);
|
||||
}
|
||||
|
||||
const binaryData = item.binary[binaryPropertyName] as IBinaryData;
|
||||
@@ -415,12 +416,12 @@ export class Cortex implements INodeType {
|
||||
const item = items[i];
|
||||
|
||||
if (item.binary === undefined) {
|
||||
throw new Error('No binary data exists on item!');
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!');
|
||||
}
|
||||
|
||||
const binaryPropertyName = (body.data as IDataObject).binaryPropertyName as string;
|
||||
if (item.binary[binaryPropertyName] === undefined) {
|
||||
throw new Error(`No binary data property "${binaryPropertyName}" does not exists on item!`);
|
||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`);
|
||||
}
|
||||
|
||||
const fileBufferData = Buffer.from(item.binary[binaryPropertyName].data, BINARY_ENCODING);
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IDataObject, NodeApiError, NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import * as moment from 'moment';
|
||||
@@ -26,7 +26,7 @@ export async function cortexApiRequest(this: IHookFunctions | IExecuteFunctions
|
||||
const credentials = this.getCredentials('cortexApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const headerWithAuthentication = Object.assign({}, { Authorization: ` Bearer ${credentials.cortexApiKey}` });
|
||||
@@ -53,10 +53,7 @@ export async function cortexApiRequest(this: IHookFunctions | IExecuteFunctions
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
if (error.error) {
|
||||
const errorMessage = `Cortex error response [${error.statusCode}]: ${error.error.message}`;
|
||||
throw new Error(errorMessage);
|
||||
} else throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -188,7 +189,7 @@ export class CrateDb implements INodeType {
|
||||
const credentials = this.getCredentials('crateDb');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const pgp = pgPromise();
|
||||
@@ -262,7 +263,7 @@ export class CrateDb implements INodeType {
|
||||
updateKeyValue = item.json[updateKey] as string | number;
|
||||
|
||||
if (updateKeyValue === undefined) {
|
||||
throw new Error('No value found for update key!');
|
||||
throw new NodeOperationError(this.getNode(), 'No value found for update key!');
|
||||
}
|
||||
|
||||
updatedKeys.push(updateKeyValue as string);
|
||||
@@ -277,7 +278,7 @@ export class CrateDb implements INodeType {
|
||||
returnItems = this.helpers.returnJsonArray(getItemCopy(items, columns) as IDataObject[]);
|
||||
} else {
|
||||
await pgp.end();
|
||||
throw new Error(`The operation "${operation}" is not supported!`);
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`);
|
||||
}
|
||||
|
||||
// Close the connection
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
import {
|
||||
customerIoApiRequest,
|
||||
@@ -131,7 +132,7 @@ export class CustomerIo implements INodeType {
|
||||
Object.assign(body, JSON.parse(additionalFieldsJson));
|
||||
|
||||
} else {
|
||||
throw new Error('Additional fields must be a valid JSON');
|
||||
throw new NodeOperationError(this.getNode(), 'Additional fields must be a valid JSON');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -175,7 +176,7 @@ export class CustomerIo implements INodeType {
|
||||
Object.assign(body, JSON.parse(additionalFieldsJson));
|
||||
|
||||
} else {
|
||||
throw new Error('Additional fields must be a valid JSON');
|
||||
throw new NodeOperationError(this.getNode(), 'Additional fields must be a valid JSON');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -238,7 +239,7 @@ export class CustomerIo implements INodeType {
|
||||
if (validateJSON(additionalFieldsJson) !== undefined) {
|
||||
Object.assign(body, JSON.parse(additionalFieldsJson));
|
||||
} else {
|
||||
throw new Error('Additional fields must be a valid JSON');
|
||||
throw new NodeOperationError(this.getNode(), 'Additional fields must be a valid JSON');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -283,7 +284,7 @@ export class CustomerIo implements INodeType {
|
||||
Object.assign(body, JSON.parse(additionalFieldsJson));
|
||||
|
||||
} else {
|
||||
throw new Error('Additional fields must be a valid JSON');
|
||||
throw new NodeOperationError(this.getNode(), 'Additional fields must be a valid JSON');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -308,7 +308,7 @@ export class CustomerIoTrigger implements INodeType {
|
||||
const endpoint = `/reporting_webhooks/${webhookData.webhookId}`;
|
||||
try {
|
||||
await customerIoApiRequest.call(this, 'DELETE', endpoint, {}, 'beta');
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
delete webhookData.webhookId;
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from 'request';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IDataObject, NodeApiError, NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -20,7 +20,7 @@ export async function customerIoApiRequest(this: IHookFunctions | IExecuteFuncti
|
||||
const credentials = this.getCredentials('customerIoApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
query = query || {};
|
||||
@@ -51,19 +51,7 @@ export async function customerIoApiRequest(this: IHookFunctions | IExecuteFuncti
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
if (error.statusCode === 401) {
|
||||
// Return a clear error
|
||||
throw new Error('The Customer.io credentials are not valid!');
|
||||
}
|
||||
|
||||
if (error.response && error.response.body && error.response.body.error_code) {
|
||||
// Try to return the error prettier
|
||||
const errorBody = error.response.body;
|
||||
throw new Error(`Customer.io error response [${errorBody.error_code}]: ${errorBody.description}`);
|
||||
}
|
||||
|
||||
// Expected error data did not get returned so throw the actual error
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
|
||||
@@ -244,7 +245,7 @@ export class DateTime implements INodeType {
|
||||
continue;
|
||||
}
|
||||
if (options.fromFormat === undefined && !moment(currentDate as string | number).isValid()) {
|
||||
throw new Error('The date input format could not be recognized. Please set the "From Format" field');
|
||||
throw new NodeOperationError(this.getNode(), 'The date input format could not be recognized. Please set the "From Format" field');
|
||||
}
|
||||
|
||||
if (Number.isInteger(currentDate as unknown as number)) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IDataObject, NodeApiError, NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function deepLApiRequest(
|
||||
@@ -45,7 +45,7 @@ export async function deepLApiRequest(
|
||||
const credentials = this.getCredentials('deepLApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
options.qs.auth_key = credentials.apiKey;
|
||||
@@ -53,10 +53,6 @@ export async function deepLApiRequest(
|
||||
return await this.helpers.request!(options);
|
||||
|
||||
} catch (error) {
|
||||
if (error?.response?.body?.message) {
|
||||
// Try to return the error prettier
|
||||
throw new Error(`DeepL error response [${error.statusCode}]: ${error.response.body.message}`);
|
||||
}
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,14 +10,14 @@ import {
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IDataObject, NodeApiError, NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function demioApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
try {
|
||||
const credentials = this.getCredentials('demioApi');
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
let options: OptionsWithUri = {
|
||||
headers: {
|
||||
@@ -35,14 +35,6 @@ export async function demioApiRequest(this: IHookFunctions | IExecuteFunctions |
|
||||
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
|
||||
if (error.response && error.response.body && error.response.body.message) {
|
||||
// Try to return the error prettier
|
||||
const errorBody = error.response.body;
|
||||
throw new Error(`Demio error response [${error.statusCode}]: ${errorBody.message}`);
|
||||
}
|
||||
|
||||
// Expected error data did not get returned so throw the actual error
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export class Discord implements INodeType {
|
||||
@@ -86,15 +88,14 @@ export class Discord implements INodeType {
|
||||
}, get(error, 'response.body.retry_after', 150));
|
||||
});
|
||||
} else {
|
||||
// If it's another error code then return the JSON response
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
} while (--maxTries);
|
||||
|
||||
if (maxTries <= 0) {
|
||||
throw new Error('Could not send message. Max. amount of rate-limit retries got reached.');
|
||||
throw new NodeApiError(this.getNode(), { request: options }, { message: 'Could not send message. Max. amount of rate-limit retries got reached.' });
|
||||
}
|
||||
|
||||
returnData.push({success: true});
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IDataObject, NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function discourseApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, path: string, body: any = {}, qs: IDataObject = {}, option = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
@@ -35,15 +35,7 @@ export async function discourseApiRequest(this: IExecuteFunctions | IExecuteSing
|
||||
//@ts-ignore
|
||||
return await this.helpers.request.call(this, options);
|
||||
} catch (error) {
|
||||
if (error.response && error.response.body && error.response.body.errors) {
|
||||
|
||||
const errors = error.response.body.errors;
|
||||
// Try to return the error prettier
|
||||
throw new Error(
|
||||
`Discourse error response [${error.statusCode}]: ${errors.join('|')}`,
|
||||
);
|
||||
}
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { disqusApiRequest, disqusApiRequestAllItems } from './GenericFunctions';
|
||||
@@ -771,11 +772,11 @@ export class Disqus implements INodeType {
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new Error(`The operation "${operation}" is not known!`);
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`);
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new Error(`The resource "${resource}" is not known!`);
|
||||
throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
IHookFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IDataObject } from 'n8n-workflow';
|
||||
import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow';
|
||||
|
||||
export async function disqusApiRequest(
|
||||
this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
|
||||
@@ -19,7 +19,7 @@ export async function disqusApiRequest(
|
||||
const credentials = this.getCredentials('disqusApi') as IDataObject;
|
||||
qs.api_key = credentials.accessToken;
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
// Convert to query string into a format the API can read
|
||||
@@ -46,21 +46,9 @@ export async function disqusApiRequest(
|
||||
delete options.body;
|
||||
}
|
||||
try {
|
||||
const result = await this.helpers.request!(options);
|
||||
return result;
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
if (error.statusCode === 401) {
|
||||
// Return a clear error
|
||||
throw new Error('The Disqus credentials are not valid!');
|
||||
}
|
||||
|
||||
if (error.error && error.error.error_summary) {
|
||||
// Try to return the error prettier
|
||||
throw new Error(`Disqus error response [${error.statusCode}]: ${error.error.error_summary}`);
|
||||
}
|
||||
|
||||
// If that data does not exist for some reason return the actual error
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@ import {
|
||||
import {
|
||||
IDataObject,
|
||||
IHookFunctions,
|
||||
IWebhookFunctions
|
||||
IWebhookFunctions,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function driftApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
@@ -36,7 +38,7 @@ export async function driftApiRequest(this: IExecuteFunctions | IWebhookFunction
|
||||
const credentials = this.getCredentials('driftApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
options.headers!['Authorization'] = `Bearer ${credentials.accessToken}`;
|
||||
@@ -46,11 +48,6 @@ export async function driftApiRequest(this: IExecuteFunctions | IWebhookFunction
|
||||
return await this.helpers.requestOAuth2!.call(this, 'driftOAuth2Api', options);
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
if (error.response && error.response.body && error.response.body.error) {
|
||||
const errorMessage = error.response.body.error.message;
|
||||
throw new Error(`Drift error response [${error.statusCode}]: ${errorMessage}`);
|
||||
}
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -849,13 +850,13 @@ export class Dropbox implements INodeType {
|
||||
const item = items[i];
|
||||
|
||||
if (item.binary === undefined) {
|
||||
throw new Error('No binary data exists on item!');
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!');
|
||||
}
|
||||
|
||||
const propertyNameUpload = this.getNodeParameter('binaryPropertyName', i) as string;
|
||||
|
||||
if (item.binary[propertyNameUpload] === undefined) {
|
||||
throw new Error(`No binary data property "${propertyNameUpload}" does not exists on item!`);
|
||||
throw new NodeOperationError(this.getNode(), `No binary data property "${propertyNameUpload}" does not exists on item!`);
|
||||
}
|
||||
|
||||
body = Buffer.from(item.binary[propertyNameUpload].data, BINARY_ENCODING);
|
||||
@@ -980,7 +981,7 @@ export class Dropbox implements INodeType {
|
||||
endpoint = 'https://api.dropboxapi.com/2/files/move_v2';
|
||||
}
|
||||
} else {
|
||||
throw new Error(`The resource "${resource}" is not known!`);
|
||||
throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`);
|
||||
}
|
||||
|
||||
if (resource === 'file' && operation === 'download') {
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
} from 'request';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IDataObject, NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
/**
|
||||
@@ -51,20 +51,7 @@ export async function dropboxApiRequest(this: IHookFunctions | IExecuteFunctions
|
||||
return await this.helpers.requestOAuth2.call(this, 'dropboxOAuth2Api', options);
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.statusCode === 401) {
|
||||
// Return a clear error
|
||||
throw new Error('The Dropbox credentials are not valid!');
|
||||
}
|
||||
|
||||
if (error.error && error.error.error_summary) {
|
||||
// Try to return the error prettier
|
||||
throw new Error(
|
||||
`Dropbox error response [${error.statusCode}]: ${error.error.error_summary}`,
|
||||
);
|
||||
}
|
||||
|
||||
// If that data does not exist for some reason return the actual error
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -206,7 +207,7 @@ export class ERPNext implements INodeType {
|
||||
const properties = this.getNodeParameter('properties', i) as DocumentProperties;
|
||||
|
||||
if (!properties.customProperty.length) {
|
||||
throw new Error('Please enter at least one property for the document to create.');
|
||||
throw new NodeOperationError(this.getNode(), 'Please enter at least one property for the document to create.');
|
||||
}
|
||||
|
||||
properties.customProperty.forEach(property => {
|
||||
@@ -242,7 +243,7 @@ export class ERPNext implements INodeType {
|
||||
const properties = this.getNodeParameter('properties', i) as DocumentProperties;
|
||||
|
||||
if (!properties.customProperty.length) {
|
||||
throw new Error('Please enter at least one property for the document to update.');
|
||||
throw new NodeOperationError(this.getNode(), 'Please enter at least one property for the document to update.');
|
||||
}
|
||||
|
||||
properties.customProperty.forEach(property => {
|
||||
|
||||
@@ -10,7 +10,9 @@ import {
|
||||
import {
|
||||
IDataObject,
|
||||
IHookFunctions,
|
||||
IWebhookFunctions
|
||||
IWebhookFunctions,
|
||||
NodeApiError,
|
||||
NodeOperationError
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function erpNextApiRequest(
|
||||
@@ -26,7 +28,7 @@ export async function erpNextApiRequest(
|
||||
const credentials = this.getCredentials('erpNextApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
let options: OptionsWithUri = {
|
||||
@@ -56,27 +58,15 @@ export async function erpNextApiRequest(
|
||||
} catch (error) {
|
||||
|
||||
if (error.statusCode === 403) {
|
||||
throw new Error(
|
||||
`ERPNext error response [${error.statusCode}]: DocType unavailable.`,
|
||||
);
|
||||
throw new NodeApiError(this.getNode(), { message: `DocType unavailable.` });
|
||||
}
|
||||
|
||||
if (error.statusCode === 307) {
|
||||
throw new Error(
|
||||
`ERPNext error response [${error.statusCode}]: Please ensure the subdomain is correct.`,
|
||||
);
|
||||
throw new NodeApiError(this.getNode(), { message:`Please ensure the subdomain is correct.` });
|
||||
}
|
||||
|
||||
let errorMessages;
|
||||
if (error?.response?.body?._server_messages) {
|
||||
const errors = JSON.parse(error.response.body._server_messages);
|
||||
errorMessages = errors.map((e: string) => JSON.parse(e).message);
|
||||
throw new Error(
|
||||
`ARPNext error response [${error.statusCode}]: ${errorMessages.join('|')}`,
|
||||
);
|
||||
}
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
import * as gm from 'gm';
|
||||
import { file } from 'tmp-promise';
|
||||
@@ -1041,7 +1042,7 @@ export class EditImage implements INodeType {
|
||||
requiredOperationParameters[operation].forEach(parameterName => {
|
||||
try {
|
||||
operationParameters[parameterName] = this.getNodeParameter(parameterName, itemIndex);
|
||||
} catch (e) {}
|
||||
} catch (error) {}
|
||||
});
|
||||
|
||||
operations = [
|
||||
@@ -1055,11 +1056,11 @@ export class EditImage implements INodeType {
|
||||
if (operations[0].operation !== 'create') {
|
||||
// "create" generates a new image so does not require any incoming data.
|
||||
if (item.binary === undefined) {
|
||||
throw new Error('Item does not contain any binary data.');
|
||||
throw new NodeOperationError(this.getNode(), 'Item does not contain any binary data.');
|
||||
}
|
||||
|
||||
if (item.binary[dataPropertyName as string] === undefined) {
|
||||
throw new Error(`Item does not contain any binary data with the name "${dataPropertyName}".`);
|
||||
throw new NodeOperationError(this.getNode(), `Item does not contain any binary data with the name "${dataPropertyName}".`);
|
||||
}
|
||||
|
||||
gmInstance = gm(Buffer.from(item.binary![dataPropertyName as string].data, BINARY_ENCODING));
|
||||
@@ -1095,7 +1096,7 @@ export class EditImage implements INodeType {
|
||||
const geometryString = (positionX >= 0 ? '+' : '') + positionX + (positionY >= 0 ? '+' : '') + positionY;
|
||||
|
||||
if (item.binary![operationData.dataPropertyNameComposite as string] === undefined) {
|
||||
throw new Error(`Item does not contain any binary data with the name "${operationData.dataPropertyNameComposite}".`);
|
||||
throw new NodeOperationError(this.getNode(), `Item does not contain any binary data with the name "${operationData.dataPropertyNameComposite}".`);
|
||||
}
|
||||
|
||||
const { fd, path, cleanup } = await file();
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IDataObject, NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
interface IContact {
|
||||
@@ -58,20 +58,7 @@ export async function egoiApiRequest(this: IHookFunctions | IExecuteFunctions |
|
||||
return await this.helpers.request!(options);
|
||||
|
||||
} catch (error) {
|
||||
let errorMessage;
|
||||
|
||||
if (error.response && error.response.body) {
|
||||
|
||||
if (Array.isArray(error.response.body.errors)) {
|
||||
const errors = error.response.body.errors;
|
||||
errorMessage = errors.map((e: IDataObject) => e.detail);
|
||||
} else {
|
||||
errorMessage = error.response.body.detail;
|
||||
}
|
||||
|
||||
throw new Error(`e-goi Error response [${error.statusCode}]: ${errorMessage}`);
|
||||
}
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
ITriggerResponse,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -168,7 +169,7 @@ export class EmailReadImap implements INodeType {
|
||||
const credentials = this.getCredentials('imap');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const mailbox = this.getNodeParameter('mailbox') as string;
|
||||
@@ -181,8 +182,8 @@ export class EmailReadImap implements INodeType {
|
||||
if (options.customEmailConfig !== undefined) {
|
||||
try {
|
||||
searchCriteria = JSON.parse(options.customEmailConfig as string);
|
||||
} catch (err) {
|
||||
throw new Error(`Custom email config is not valid JSON.`);
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(this.getNode(), `Custom email config is not valid JSON.`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +280,7 @@ export class EmailReadImap implements INodeType {
|
||||
const part = lodash.find(message.parts, { which: '' });
|
||||
|
||||
if (part === undefined) {
|
||||
throw new Error('Email part could not be parsed.');
|
||||
throw new NodeOperationError(this.getNode(), 'Email part could not be parsed.');
|
||||
}
|
||||
const parsedEmail = await parseRawEmail.call(this, part.body, dataPropertyAttachmentsPrefixName);
|
||||
|
||||
@@ -337,7 +338,7 @@ export class EmailReadImap implements INodeType {
|
||||
const part = lodash.find(message.parts, { which: 'TEXT' });
|
||||
|
||||
if (part === undefined) {
|
||||
throw new Error('Email part could not be parsed.');
|
||||
throw new NodeOperationError(this.getNode(), 'Email part could not be parsed.');
|
||||
}
|
||||
// Return base64 string
|
||||
newEmail = {
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { createTransport } from 'nodemailer';
|
||||
@@ -148,7 +149,7 @@ export class EmailSend implements INodeType {
|
||||
const credentials = this.getCredentials('smtp');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const connectionOptions: SMTPTransport.Options = {
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
import {
|
||||
IHookFunctions,
|
||||
INodePropertyOptions,
|
||||
NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
/**
|
||||
@@ -18,7 +19,7 @@ export async function emeliaGraphqlRequest(
|
||||
const response = await emeliaApiRequest.call(this, 'POST', '/graphql', body);
|
||||
|
||||
if (response.errors) {
|
||||
throw new Error(`Emelia error message: ${response.errors[0].message}`);
|
||||
throw new NodeApiError(this.getNode(), response);
|
||||
}
|
||||
|
||||
return response;
|
||||
@@ -48,19 +49,9 @@ export async function emeliaApiRequest(
|
||||
};
|
||||
|
||||
try {
|
||||
|
||||
return await this.helpers.request!.call(this, options);
|
||||
|
||||
} catch (error) {
|
||||
|
||||
if (error?.response?.body?.error) {
|
||||
const { error: errorMessage } = error.response.body;
|
||||
throw new Error(
|
||||
`Emelia error response [${error.statusCode}]: ${errorMessage}`,
|
||||
);
|
||||
}
|
||||
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IWebhookResponseData,
|
||||
NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -292,7 +293,7 @@ export class EventbriteTrigger implements INodeType {
|
||||
const req = this.getRequestObject();
|
||||
|
||||
if (req.body.api_url === undefined) {
|
||||
throw new Error('The received data does not contain required "api_url" property!');
|
||||
throw new NodeApiError(this.getNode(), req.body, { message: 'The received data does not contain required "api_url" property!' });
|
||||
}
|
||||
|
||||
const resolveData = this.getNodeParameter('resolveData', false) as boolean;
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IDataObject, NodeApiError, NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function eventbriteApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
@@ -34,7 +34,7 @@ export async function eventbriteApiRequest(this: IHookFunctions | IExecuteFuncti
|
||||
if (authenticationMethod === 'privateKey') {
|
||||
const credentials = this.getCredentials('eventbriteApi');
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
options.headers!['Authorization'] = `Bearer ${credentials.apiKey}`;
|
||||
@@ -44,11 +44,7 @@ export async function eventbriteApiRequest(this: IHookFunctions | IExecuteFuncti
|
||||
return await this.helpers.requestOAuth2!.call(this, 'eventbriteOAuth2Api', options);
|
||||
}
|
||||
} catch (error) {
|
||||
let errorMessage = error.message;
|
||||
if (error.response.body && error.response.body.error_description) {
|
||||
errorMessage = error.response.body.error_description;
|
||||
}
|
||||
throw new Error('Eventbrite Error: ' + errorMessage);
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IWorkflowBase,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
|
||||
@@ -164,7 +165,7 @@ export class ExecuteWorkflow implements INodeType {
|
||||
workflowJson = await fsReadFileAsync(workflowPath, { encoding: 'utf8' }) as string;
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
throw new Error(`The file "${workflowPath}" could not be found.`);
|
||||
throw new NodeOperationError(this.getNode(), `The file "${workflowPath}" could not be found.`);
|
||||
}
|
||||
|
||||
throw error;
|
||||
|
||||
@@ -8,6 +8,8 @@ import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -365,7 +367,7 @@ export class FacebookGraphApi implements INodeType {
|
||||
if (sendBinaryData) {
|
||||
const item = items[itemIndex];
|
||||
if (item.binary === undefined) {
|
||||
throw new Error('No binary data exists on item!');
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!');
|
||||
}
|
||||
|
||||
const binaryPropertyNameFull = this.getNodeParameter('binaryPropertyName', itemIndex) as string;
|
||||
@@ -379,7 +381,7 @@ export class FacebookGraphApi implements INodeType {
|
||||
}
|
||||
|
||||
if (item.binary[binaryPropertyName] === undefined) {
|
||||
throw new Error(`No binary data property "${binaryPropertyName}" does not exists on item!`);
|
||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`);
|
||||
}
|
||||
|
||||
const binaryProperty = item.binary[binaryPropertyName] as IBinaryData;
|
||||
@@ -400,7 +402,7 @@ export class FacebookGraphApi implements INodeType {
|
||||
response = await this.helpers.request(requestOptions);
|
||||
} catch (error) {
|
||||
if (this.continueOnFail() === false) {
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
|
||||
let errorItem;
|
||||
@@ -425,7 +427,7 @@ export class FacebookGraphApi implements INodeType {
|
||||
|
||||
if (typeof response === 'string') {
|
||||
if (this.continueOnFail() === false) {
|
||||
throw new Error('Response body is not valid JSON.');
|
||||
throw new NodeOperationError(this.getNode(), 'Response body is not valid JSON.');
|
||||
}
|
||||
|
||||
returnItems.push({ json: { message: response } });
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IWebhookResponseData,
|
||||
NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import * as uuid from 'uuid/v4';
|
||||
@@ -192,7 +193,7 @@ export class FacebookTrigger implements INodeType {
|
||||
|
||||
if (responseData.success !== true) {
|
||||
// Facebook did not return success, so something went wrong
|
||||
throw new Error('Facebook webhook creation response did not contain the expected data.');
|
||||
throw new NodeApiError(this.getNode(), responseData, { message: 'Facebook webhook creation response did not contain the expected data.' });
|
||||
}
|
||||
return true;
|
||||
},
|
||||
@@ -202,7 +203,7 @@ export class FacebookTrigger implements INodeType {
|
||||
|
||||
try {
|
||||
await facebookApiRequest.call(this, 'DELETE', `/${appId}/subscriptions`, { object: snakeCase(object) });
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IDataObject, NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function facebookApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
@@ -41,13 +41,6 @@ export async function facebookApiRequest(this: IHookFunctions | IExecuteFunction
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
|
||||
if (error.response.body && error.response.body.error) {
|
||||
const message = error.response.body.error.message;
|
||||
throw new Error(
|
||||
`Facebook Trigger error response [${error.statusCode}]: ${message}`,
|
||||
);
|
||||
}
|
||||
throw new Error(error);
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
INodeExecutionData, INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
|
||||
@@ -680,8 +681,8 @@ export class FileMaker implements INodeType {
|
||||
|
||||
try {
|
||||
returnData = await layoutsApiRequest.call(this);
|
||||
} catch (err) {
|
||||
throw new Error(`FileMaker Error: ${err}`);
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(this.getNode(), `FileMaker Error: ${error}`);
|
||||
}
|
||||
|
||||
return returnData;
|
||||
@@ -696,8 +697,8 @@ export class FileMaker implements INodeType {
|
||||
let layouts;
|
||||
try {
|
||||
layouts = await layoutsApiRequest.call(this);
|
||||
} catch (err) {
|
||||
throw new Error(`FileMaker Error: ${err}`);
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(this.getNode(), `FileMaker Error: ${error}`);
|
||||
}
|
||||
for (const layout of layouts) {
|
||||
returnData.push({
|
||||
@@ -714,8 +715,8 @@ export class FileMaker implements INodeType {
|
||||
let fields;
|
||||
try {
|
||||
fields = await getFields.call(this);
|
||||
} catch (err) {
|
||||
throw new Error(`FileMaker Error: ${err}`);
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(this.getNode(), `FileMaker Error: ${error}`);
|
||||
}
|
||||
for (const field of fields) {
|
||||
returnData.push({
|
||||
@@ -732,8 +733,8 @@ export class FileMaker implements INodeType {
|
||||
let scripts;
|
||||
try {
|
||||
scripts = await getScripts.call(this);
|
||||
} catch (err) {
|
||||
throw new Error(`FileMaker Error: ${err}`);
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(this.getNode(), `FileMaker Error: ${error}`);
|
||||
}
|
||||
for (const script of scripts) {
|
||||
if (!script.isFolder) {
|
||||
@@ -752,8 +753,8 @@ export class FileMaker implements INodeType {
|
||||
let portals;
|
||||
try {
|
||||
portals = await getPortals.call(this);
|
||||
} catch (err) {
|
||||
throw new Error(`FileMaker Error: ${err}`);
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(this.getNode(), `FileMaker Error: ${error}`);
|
||||
}
|
||||
Object.keys(portals).forEach((portal) => {
|
||||
returnData.push({
|
||||
@@ -775,14 +776,14 @@ export class FileMaker implements INodeType {
|
||||
const credentials = this.getCredentials('fileMaker');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
let token;
|
||||
try {
|
||||
token = await getToken.call(this);
|
||||
} catch (e) {
|
||||
throw new Error(`Login fail: ${e}`);
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(this.getNode(), `Login fail: ${error}`);
|
||||
}
|
||||
|
||||
let requestOptions: OptionsWithUri;
|
||||
@@ -886,7 +887,7 @@ export class FileMaker implements INodeType {
|
||||
...parseScripts.call(this, i),
|
||||
};
|
||||
} else {
|
||||
throw new Error(`The action "${action}" is not implemented yet!`);
|
||||
throw new NodeOperationError(this.getNode(), `The action "${action}" is not implemented yet!`);
|
||||
}
|
||||
|
||||
// Now that the options are all set make the actual http request
|
||||
@@ -898,13 +899,18 @@ export class FileMaker implements INodeType {
|
||||
}
|
||||
|
||||
if (typeof response === 'string') {
|
||||
throw new Error('Response body is not valid JSON. Change "Response Format" to "String"');
|
||||
throw new NodeOperationError(this.getNode(), 'Response body is not valid JSON. Change "Response Format" to "String"');
|
||||
}
|
||||
returnData.push({json: response});
|
||||
}
|
||||
} catch (error) {
|
||||
await logout.call(this, token);
|
||||
throw new Error(`The action "${error.message}" is not implemented yet!`);
|
||||
|
||||
if (error.node) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
throw new NodeOperationError(this.getNode(), `The action "${error.message}" is not implemented yet!`);
|
||||
}
|
||||
|
||||
return this.prepareOutputData(returnData);
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject, INodePropertyOptions,
|
||||
IDataObject, INodePropertyOptions, NodeApiError, NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {OptionsWithUri} from 'request';
|
||||
@@ -42,7 +42,7 @@ export async function layoutsApiRequest(this: ILoadOptionsFunctions | IExecuteFu
|
||||
const credentials = this.getCredentials('fileMaker');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
const host = credentials.host as string;
|
||||
const db = credentials.db as string;
|
||||
@@ -63,8 +63,7 @@ export async function layoutsApiRequest(this: ILoadOptionsFunctions | IExecuteFu
|
||||
items.sort((a, b) => a.name > b.name ? 0 : 1);
|
||||
return items;
|
||||
} catch (error) {
|
||||
// If that data does not exist for some reason return the actual error
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +93,7 @@ export async function getFields(this: ILoadOptionsFunctions): Promise<any> { //
|
||||
const layout = this.getCurrentNodeParameter('layout') as string;
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
const host = credentials.host as string;
|
||||
const db = credentials.db as string;
|
||||
@@ -130,7 +129,7 @@ export async function getPortals(this: ILoadOptionsFunctions): Promise<any> { //
|
||||
const layout = this.getCurrentNodeParameter('layout') as string;
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
const host = credentials.host as string;
|
||||
const db = credentials.db as string;
|
||||
@@ -165,7 +164,7 @@ export async function getScripts(this: ILoadOptionsFunctions): Promise<any> { //
|
||||
const credentials = this.getCredentials('fileMaker');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
const host = credentials.host as string;
|
||||
const db = credentials.db as string;
|
||||
@@ -210,7 +209,7 @@ function parseScriptsList(scripts: ScriptObject[]): INodePropertyOptions[] {
|
||||
export async function getToken(this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('fileMaker');
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const host = credentials.host as string;
|
||||
@@ -247,28 +246,19 @@ export async function getToken(this: ILoadOptionsFunctions | IExecuteFunctions |
|
||||
const response = await this.helpers.request!(requestOptions);
|
||||
|
||||
if (typeof response === 'string') {
|
||||
throw new Error('Response body is not valid JSON. Change "Response Format" to "String"');
|
||||
throw new NodeOperationError(this.getNode(), 'Response body is not valid JSON. Change "Response Format" to "String"');
|
||||
}
|
||||
|
||||
return response.response.token;
|
||||
} catch (error) {
|
||||
let errorMessage;
|
||||
if (error.response) {
|
||||
errorMessage = error.response.body.messages[0].message + '(' + error.response.body.messages[0].message + ')';
|
||||
} else {
|
||||
errorMessage = `${error.message} (${error.name})`;
|
||||
}
|
||||
if (errorMessage !== undefined) {
|
||||
throw errorMessage;
|
||||
}
|
||||
throw error.message;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function logout(this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions, token: string): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('fileMaker');
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const host = credentials.host as string;
|
||||
@@ -290,7 +280,7 @@ export async function logout(this: ILoadOptionsFunctions | IExecuteFunctions | I
|
||||
const response = await this.helpers.request!(requestOptions);
|
||||
|
||||
if (typeof response === 'string') {
|
||||
throw new Error('Response body is not valid JSON. Change "Response Format" to "String"');
|
||||
throw new NodeOperationError(this.getNode(), 'Response body is not valid JSON. Change "Response Format" to "String"');
|
||||
}
|
||||
|
||||
return response;
|
||||
|
||||
@@ -6,6 +6,8 @@ import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
import {
|
||||
flowApiRequest,
|
||||
@@ -64,7 +66,7 @@ export class Flow implements INodeType {
|
||||
const credentials = this.getCredentials('flowApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const items = this.getInputData();
|
||||
@@ -135,8 +137,8 @@ export class Flow implements INodeType {
|
||||
try {
|
||||
responseData = await flowApiRequest.call(this, 'POST', '/tasks', body);
|
||||
responseData = responseData.task;
|
||||
} catch (err) {
|
||||
throw new Error(`Flow Error: ${err.message}`);
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
//https://developer.getflow.com/api/#tasks_update-a-task
|
||||
@@ -203,8 +205,8 @@ export class Flow implements INodeType {
|
||||
try {
|
||||
responseData = await flowApiRequest.call(this, 'PUT', `/tasks/${taskId}`, body);
|
||||
responseData = responseData.task;
|
||||
} catch (err) {
|
||||
throw new Error(`Flow Error: ${err.message}`);
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
//https://developer.getflow.com/api/#tasks_get-task
|
||||
@@ -217,8 +219,8 @@ export class Flow implements INodeType {
|
||||
}
|
||||
try {
|
||||
responseData = await flowApiRequest.call(this,'GET', `/tasks/${taskId}`, {}, qs);
|
||||
} catch (err) {
|
||||
throw new Error(`Flow Error: ${err.message}`);
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
//https://developer.getflow.com/api/#tasks_get-tasks
|
||||
@@ -261,8 +263,8 @@ export class Flow implements INodeType {
|
||||
responseData = await flowApiRequest.call(this, 'GET', '/tasks', {}, qs);
|
||||
responseData = responseData.tasks;
|
||||
}
|
||||
} catch (err) {
|
||||
throw new Error(`Flow Error: ${err.message}`);
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IWebhookResponseData,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -111,7 +112,7 @@ export class FlowTrigger implements INodeType {
|
||||
const credentials = this.getCredentials('flowApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
let webhooks;
|
||||
@@ -128,8 +129,8 @@ export class FlowTrigger implements INodeType {
|
||||
try {
|
||||
webhooks = await flowApiRequest.call(this, 'GET', endpoint, {}, qs);
|
||||
webhooks = webhooks.integration_webhooks;
|
||||
} catch (e) {
|
||||
throw e;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
for (const webhook of webhooks) {
|
||||
// @ts-ignore
|
||||
@@ -145,7 +146,7 @@ export class FlowTrigger implements INodeType {
|
||||
const credentials = this.getCredentials('flowApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
let resourceIds, body, responseData;
|
||||
@@ -189,7 +190,7 @@ export class FlowTrigger implements INodeType {
|
||||
const credentials = this.getCredentials('flowApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const qs: IDataObject = {};
|
||||
@@ -202,7 +203,7 @@ export class FlowTrigger implements INodeType {
|
||||
const endpoint = `/integration_webhooks/${webhookId}`;
|
||||
try {
|
||||
await flowApiRequest.call(this, 'DELETE', endpoint, {}, qs);
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@ import {
|
||||
IHookFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IDataObject } from 'n8n-workflow';
|
||||
import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow';
|
||||
|
||||
export async function flowApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('flowApi');
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
let options: OptionsWithUri = {
|
||||
@@ -29,12 +29,7 @@ export async function flowApiRequest(this: IHookFunctions | IExecuteFunctions |
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
let errorMessage = error.message;
|
||||
if (error.response.body) {
|
||||
errorMessage = error.response.body.message || error.response.body.Message || error.message;
|
||||
}
|
||||
|
||||
throw new Error(errorMessage);
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -1169,7 +1170,7 @@ export class Freshdesk implements INodeType {
|
||||
if (requester === 'requesterId') {
|
||||
// @ts-ignore
|
||||
if (isNaN(value)) {
|
||||
throw new Error('Requester Id must be a number');
|
||||
throw new NodeOperationError(this.getNode(), 'Requester Id must be a number');
|
||||
}
|
||||
body.requester_id = parseInt(value, 10);
|
||||
} else if (requester === 'email') {
|
||||
@@ -1254,7 +1255,7 @@ export class Freshdesk implements INodeType {
|
||||
if (updateFields.requester === 'requesterId') {
|
||||
// @ts-ignore
|
||||
if (isNaN(parseInt(value, 10))) {
|
||||
throw new Error('Requester Id must be a number');
|
||||
throw new NodeOperationError(this.getNode(), 'Requester Id must be a number');
|
||||
}
|
||||
body.requester_id = parseInt(value as string, 10);
|
||||
} else if (updateFields.requester === 'email') {
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IDataObject, NodeApiError, NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function freshdeskApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
@@ -17,7 +17,7 @@ export async function freshdeskApiRequest(this: IExecuteFunctions | ILoadOptions
|
||||
const credentials = this.getCredentials('freshdeskApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const apiKey = `${credentials.apiKey}:X`;
|
||||
@@ -45,15 +45,7 @@ export async function freshdeskApiRequest(this: IExecuteFunctions | ILoadOptions
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
if (error.response) {
|
||||
let errorMessage = error.response.body.message || error.response.body.description || error.message;
|
||||
if (error.response.body && error.response.body.errors) {
|
||||
errorMessage = error.response.body.errors.map((err: IDataObject) => `"${err.field}" => ${err.message}`).join(', ');
|
||||
}
|
||||
throw new Error(`Freshdesk error response [${error.statusCode}]: ${errorMessage}`);
|
||||
}
|
||||
|
||||
throw error;
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user