mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor: Remove usless catch blocks, and add a linting rule to prevent them (no-changelog) (#12730)
This commit is contained in:
committed by
GitHub
parent
4ee4552b0e
commit
202da76380
@@ -601,16 +601,12 @@ export class Disqus implements INodeType {
|
||||
|
||||
Object.assign(qs, additionalFields);
|
||||
|
||||
try {
|
||||
const responseData = await disqusApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData.response as IDataObject[]),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
const responseData = await disqusApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData.response as IDataObject[]),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'getPosts') {
|
||||
// ----------------------------------
|
||||
// getPosts
|
||||
@@ -629,28 +625,24 @@ export class Disqus implements INodeType {
|
||||
qs.forum = id;
|
||||
qs.limit = 100;
|
||||
|
||||
try {
|
||||
let responseData: IDataObject = {};
|
||||
if (returnAll) {
|
||||
responseData.response = await disqusApiRequestAllItems.call(
|
||||
this,
|
||||
requestMethod,
|
||||
qs,
|
||||
endpoint,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
qs.limit = limit;
|
||||
responseData = await disqusApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
}
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData.response as IDataObject),
|
||||
{ itemData: { item: i } },
|
||||
let responseData: IDataObject = {};
|
||||
if (returnAll) {
|
||||
responseData.response = await disqusApiRequestAllItems.call(
|
||||
this,
|
||||
requestMethod,
|
||||
qs,
|
||||
endpoint,
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
qs.limit = limit;
|
||||
responseData = await disqusApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
}
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData.response as IDataObject),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'getCategories') {
|
||||
// ----------------------------------
|
||||
// getCategories
|
||||
@@ -668,34 +660,30 @@ export class Disqus implements INodeType {
|
||||
qs.forum = id;
|
||||
qs.limit = 100;
|
||||
|
||||
try {
|
||||
let responseData: IDataObject = {};
|
||||
let responseData: IDataObject = {};
|
||||
|
||||
if (returnAll) {
|
||||
responseData.response = await disqusApiRequestAllItems.call(
|
||||
this,
|
||||
requestMethod,
|
||||
qs,
|
||||
endpoint,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
qs.limit = limit;
|
||||
responseData = (await disqusApiRequest.call(
|
||||
this,
|
||||
requestMethod,
|
||||
qs,
|
||||
endpoint,
|
||||
)) as IDataObject;
|
||||
}
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData.response as IDataObject),
|
||||
{ itemData: { item: i } },
|
||||
if (returnAll) {
|
||||
responseData.response = await disqusApiRequestAllItems.call(
|
||||
this,
|
||||
requestMethod,
|
||||
qs,
|
||||
endpoint,
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
qs.limit = limit;
|
||||
responseData = (await disqusApiRequest.call(
|
||||
this,
|
||||
requestMethod,
|
||||
qs,
|
||||
endpoint,
|
||||
)) as IDataObject;
|
||||
}
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData.response as IDataObject),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'getThreads') {
|
||||
// ----------------------------------
|
||||
// getThreads
|
||||
@@ -715,28 +703,24 @@ export class Disqus implements INodeType {
|
||||
|
||||
Object.assign(qs, additionalFields);
|
||||
|
||||
try {
|
||||
let responseData: IDataObject = {};
|
||||
if (returnAll) {
|
||||
responseData.response = await disqusApiRequestAllItems.call(
|
||||
this,
|
||||
requestMethod,
|
||||
qs,
|
||||
endpoint,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
qs.limit = limit;
|
||||
responseData = await disqusApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
}
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData.response as IDataObject),
|
||||
{ itemData: { item: i } },
|
||||
let responseData: IDataObject = {};
|
||||
if (returnAll) {
|
||||
responseData.response = await disqusApiRequestAllItems.call(
|
||||
this,
|
||||
requestMethod,
|
||||
qs,
|
||||
endpoint,
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
qs.limit = limit;
|
||||
responseData = await disqusApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
}
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData.response as IDataObject),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
} else {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
|
||||
@@ -66,14 +66,10 @@ export async function disqusApiRequestAllItems(
|
||||
|
||||
let responseData;
|
||||
|
||||
try {
|
||||
do {
|
||||
responseData = await disqusApiRequest.call(this, method, qs, uri, body, option);
|
||||
qs.cursor = responseData.cursor.id;
|
||||
returnData.push.apply(returnData, responseData.response as IDataObject[]);
|
||||
} while (responseData.cursor.more === true && responseData.cursor.hasNext === true);
|
||||
return returnData;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
do {
|
||||
responseData = await disqusApiRequest.call(this, method, qs, uri, body, option);
|
||||
qs.cursor = responseData.cursor.id;
|
||||
returnData.push.apply(returnData, responseData.response as IDataObject[]);
|
||||
} while (responseData.cursor.more === true && responseData.cursor.hasNext === true);
|
||||
return returnData;
|
||||
}
|
||||
|
||||
@@ -154,13 +154,8 @@ export async function getFields(this: ILoadOptionsFunctions): Promise<any> {
|
||||
json: true,
|
||||
};
|
||||
|
||||
try {
|
||||
const responseData = await this.helpers.request(options);
|
||||
return responseData.response.fieldMetaData;
|
||||
} catch (error) {
|
||||
// If that data does not exist for some reason return the actual error
|
||||
throw error;
|
||||
}
|
||||
const responseData = await this.helpers.request(options);
|
||||
return responseData.response.fieldMetaData;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,13 +180,8 @@ export async function getPortals(this: ILoadOptionsFunctions): Promise<any> {
|
||||
json: true,
|
||||
};
|
||||
|
||||
try {
|
||||
const responseData = await this.helpers.request(options);
|
||||
return responseData.response.portalMetaData;
|
||||
} catch (error) {
|
||||
// If that data does not exist for some reason return the actual error
|
||||
throw error;
|
||||
}
|
||||
const responseData = await this.helpers.request(options);
|
||||
return responseData.response.portalMetaData;
|
||||
}
|
||||
|
||||
function parseScriptsList(scripts: ScriptObject[]): INodePropertyOptions[] {
|
||||
@@ -230,15 +220,10 @@ export async function getScripts(this: ILoadOptionsFunctions): Promise<any> {
|
||||
json: true,
|
||||
};
|
||||
|
||||
try {
|
||||
const responseData = await this.helpers.request(options);
|
||||
const items = parseScriptsList(responseData.response.scripts as ScriptObject[]);
|
||||
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;
|
||||
}
|
||||
const responseData = await this.helpers.request(options);
|
||||
const items = parseScriptsList(responseData.response.scripts as ScriptObject[]);
|
||||
items.sort((a, b) => (a.name > b.name ? 0 : 1));
|
||||
return items;
|
||||
}
|
||||
|
||||
export async function logout(
|
||||
|
||||
@@ -107,12 +107,8 @@ export class FlowTrigger implements INodeType {
|
||||
}
|
||||
qs.organization_id = credentials.organizationId as number;
|
||||
const endpoint = '/integration_webhooks';
|
||||
try {
|
||||
webhooks = await flowApiRequest.call(this, 'GET', endpoint, {}, qs);
|
||||
webhooks = webhooks.integration_webhooks;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
webhooks = await flowApiRequest.call(this, 'GET', endpoint, {}, qs);
|
||||
webhooks = webhooks.integration_webhooks;
|
||||
for (const webhook of webhooks) {
|
||||
// @ts-ignore
|
||||
if (webhookData.webhookIds.includes(webhook.id)) {
|
||||
|
||||
@@ -16,19 +16,15 @@ export async function router(this: IExecuteFunctions): Promise<INodeExecutionDat
|
||||
operation,
|
||||
} as ItemListsType;
|
||||
|
||||
try {
|
||||
switch (itemListsNodeData.resource) {
|
||||
case 'itemList':
|
||||
returnData = await itemList[itemListsNodeData.operation].execute.call(this, items);
|
||||
break;
|
||||
default:
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not supported!`,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
throw error;
|
||||
switch (itemListsNodeData.resource) {
|
||||
case 'itemList':
|
||||
returnData = await itemList[itemListsNodeData.operation].execute.call(this, items);
|
||||
break;
|
||||
default:
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not supported!`,
|
||||
);
|
||||
}
|
||||
|
||||
return [returnData];
|
||||
|
||||
@@ -214,7 +214,6 @@ export class MailchimpTrigger implements INodeType {
|
||||
},
|
||||
|
||||
async create(this: IHookFunctions): Promise<boolean> {
|
||||
let webhook;
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
const listId = this.getNodeParameter('list') as string;
|
||||
const events = this.getNodeParameter('events', []) as string[];
|
||||
@@ -233,11 +232,7 @@ export class MailchimpTrigger implements INodeType {
|
||||
}, {}),
|
||||
};
|
||||
const endpoint = `/lists/${listId}/webhooks`;
|
||||
try {
|
||||
webhook = await mailchimpApiRequest.call(this, endpoint, 'POST', body);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
const webhook = await mailchimpApiRequest.call(this, endpoint, 'POST', body);
|
||||
if (webhook.id === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,6 @@ export class PayPalTrigger implements INodeType {
|
||||
},
|
||||
|
||||
async create(this: IHookFunctions): Promise<boolean> {
|
||||
let webhook;
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
const events = this.getNodeParameter('events', []) as string[];
|
||||
const body = {
|
||||
@@ -125,11 +124,7 @@ export class PayPalTrigger implements INodeType {
|
||||
}),
|
||||
};
|
||||
const endpoint = '/notifications/webhooks';
|
||||
try {
|
||||
webhook = await payPalApiRequest.call(this, endpoint, 'POST', body);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
const webhook = await payPalApiRequest.call(this, endpoint, 'POST', body);
|
||||
|
||||
if (webhook.id === undefined) {
|
||||
return false;
|
||||
@@ -156,7 +151,6 @@ export class PayPalTrigger implements INodeType {
|
||||
};
|
||||
|
||||
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
|
||||
let webhook;
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
const bodyData = this.getBodyData();
|
||||
const req = this.getRequestObject();
|
||||
@@ -188,11 +182,7 @@ export class PayPalTrigger implements INodeType {
|
||||
webhook_id: webhookData.webhookId,
|
||||
webhook_event: bodyData,
|
||||
};
|
||||
try {
|
||||
webhook = await payPalApiRequest.call(this, endpoint, 'POST', body);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
const webhook = await payPalApiRequest.call(this, endpoint, 'POST', body);
|
||||
if (webhook.verification_status !== 'SUCCESS') {
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -877,12 +877,7 @@ export class StripeTrigger implements INodeType {
|
||||
enabled_events: events,
|
||||
};
|
||||
|
||||
let responseData;
|
||||
try {
|
||||
responseData = await stripeApiRequest.call(this, 'POST', endpoint, body);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
const responseData = await stripeApiRequest.call(this, 'POST', endpoint, body);
|
||||
|
||||
if (
|
||||
responseData.id === undefined ||
|
||||
|
||||
@@ -16,19 +16,15 @@ export async function router(this: IExecuteFunctions): Promise<INodeExecutionDat
|
||||
operation,
|
||||
} as WebflowType;
|
||||
|
||||
try {
|
||||
switch (webflowNodeData.resource) {
|
||||
case 'item':
|
||||
returnData = await item[webflowNodeData.operation].execute.call(this, items);
|
||||
break;
|
||||
default:
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not supported!`,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
throw error;
|
||||
switch (webflowNodeData.resource) {
|
||||
case 'item':
|
||||
returnData = await item[webflowNodeData.operation].execute.call(this, items);
|
||||
break;
|
||||
default:
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not supported!`,
|
||||
);
|
||||
}
|
||||
|
||||
return [returnData];
|
||||
|
||||
Reference in New Issue
Block a user