Skip to content

Commit

Permalink
prevent NodeApiError rewraping in request functions
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-radency committed Jun 5, 2024
1 parent 5322802 commit d70d041
Show file tree
Hide file tree
Showing 215 changed files with 270 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export async function activeCampaignApiRequest(
return responseData[dataKey] as IDataObject;
}
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export async function acuitySchedulingApiRequest(
);
}
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Affinity/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export async function affinityApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export async function agileCrmApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down Expand Up @@ -168,6 +169,7 @@ export async function agileCrmApiRequestUpdate(
return lastSuccesfulUpdateReturn;
} catch (error) {
if (successfulUpdates.length === 0) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
} else {
throw new NodeApiError(this.getNode(), error as JsonObject, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export async function apiTemplateIoApiRequest(
}
return response;
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Automizy/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export async function automizyApiRequest(
//@ts-ignore
return await this.helpers.request.call(this, options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Autopilot/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export async function autopilotApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export async function awsApiRequest(
try {
return await this.helpers.requestWithAuthentication.call(this, 'aws', requestOptions);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Aws/ELB/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export async function awsApiRequest(
try {
return await this.helpers.requestWithAuthentication.call(this, 'aws', requestOptions);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/nodes-base/nodes/Aws/SQS/AwsSqs.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ export class AwsSqs implements INodeType {
// loads first 1000 queues from SQS
data = await awsApiRequestSOAP.call(this, 'sqs', 'GET', `?${params.join('&')}`);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}

Expand Down Expand Up @@ -372,6 +373,7 @@ export class AwsSqs implements INodeType {
`${queuePath}?${params.join('&')}`,
);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}

Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Aws/Textract/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export async function awsApiRequest(
}
}

if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject); // no XML parsing needed
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export async function awsApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject); // no XML parsing needed
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Bannerbear/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export async function bannerbearApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/nodes-base/nodes/Baserow/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export async function baserowApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down Expand Up @@ -104,6 +105,7 @@ export async function getJwtToken(
const { token } = (await this.helpers.request(options)) as { token: string };
return token;
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Bitbucket/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export async function bitbucketApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Bitly/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export async function bitlyApiRequest(
});
}
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export async function bitwardenApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down Expand Up @@ -99,6 +100,7 @@ export async function getAccessToken(
const { access_token } = await this.helpers.request(options);
return access_token;
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Box/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export async function boxApiRequest(
//@ts-ignore
return await this.helpers.requestOAuth2.call(this, 'boxOAuth2Api', options, oAuth2Options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Brandfetch/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export async function brandfetchApiRequest(

return response;
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Bubble/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export async function bubbleApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Chargebee/Chargebee.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ export class Chargebee implements INodeType {
try {
responseData = await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}

Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/CircleCi/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export async function circleciApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Cisco/Webex/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export async function webexApiRequest(
tokenType: 'Bearer',
});
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Citrix/ADC/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export async function citrixADCApiRequest(
try {
return await this.helpers.requestWithAuthentication.call(this, 'citrixAdcApi', options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Clearbit/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export async function clearbitApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/ClickUp/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export async function clickupApiRequest(
);
}
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Cloudflare/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export async function cloudflareApiRequest(
}
return await this.helpers.requestWithAuthentication.call(this, 'cloudflareApi', options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Cockpit/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export async function cockpitApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Coda/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export async function codaApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/CoinGecko/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export async function coinGeckoApiRequest(
//@ts-ignore
return await this.helpers.request.call(this, options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Contentful/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export async function contentfulApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export async function convertKitApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Copper/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export async function copperApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/DeepL/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export async function deepLApiRequest(

return await this.helpers.requestWithAuthentication.call(this, 'deepLApi', options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Demio/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export async function demioApiRequest(

return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Dhl/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export async function dhlApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Discourse/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export async function discourseApiRequest(
}
return await this.helpers.requestWithAuthentication.call(this, 'discourseApi', options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Disqus/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export async function disqusApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Drift/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export async function driftApiRequest(
return await this.helpers.requestOAuth2.call(this, 'driftOAuth2Api', options);
}
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Dropbox/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export async function dropboxApiRequest(
return await this.helpers.requestOAuth2.call(this, 'dropboxOAuth2Api', options);
}
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Egoi/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export async function egoiApiRequest(
try {
return await this.helpers.request(options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export async function elasticSecurityApiRequest(
error.error.error = `${error.error.error}: ${error.error.message}`;
}

if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export async function elasticsearchApiRequest(
try {
return await this.helpers.requestWithAuthentication.call(this, 'elasticsearchApi', options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down Expand Up @@ -103,6 +104,7 @@ export async function elasticsearchApiRequestAllItems(

return returnData;
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/EmailSend/v2/send.operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ export async function execute(this: IExecuteFunctions): Promise<INodeExecutionDa
continue;
}
delete error.cert;
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Emelia/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export async function emeliaApiRequest(
try {
return await this.helpers.request.call(this, options);
} catch (error) {
if (error instanceof NodeApiError) throw error;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
Expand Down
Loading

0 comments on commit d70d041

Please sign in to comment.