diff --git a/packages/nodes-base/nodes/ActionNetwork/GenericFunctions.ts b/packages/nodes-base/nodes/ActionNetwork/GenericFunctions.ts index 7582335adc..2c546dde02 100644 --- a/packages/nodes-base/nodes/ActionNetwork/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ActionNetwork/GenericFunctions.ts @@ -39,11 +39,7 @@ export async function actionNetworkApiRequest( delete options.qs; } - try { - return await this.helpers.requestWithAuthentication.call(this, 'actionNetworkApi', options); - } catch (error) { - throw new NodeApiError(this.getNode(), error); - } + return await this.helpers.requestWithAuthentication.call(this, 'actionNetworkApi', options); } export async function handleListing( diff --git a/packages/nodes-base/nodes/Airtable/GenericFunctions.ts b/packages/nodes-base/nodes/Airtable/GenericFunctions.ts index e8ebc4e02a..021da55fe6 100644 --- a/packages/nodes-base/nodes/Airtable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Airtable/GenericFunctions.ts @@ -61,11 +61,7 @@ export async function apiRequest( delete options.body; } - try { - return await this.helpers.requestWithAuthentication.call(this, 'airtableApi', options); - } catch (error) { - throw new NodeApiError(this.getNode(), error); - } + return await this.helpers.requestWithAuthentication.call(this, 'airtableApi', options); } /** diff --git a/packages/nodes-base/nodes/Aws/Comprehend/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/Comprehend/GenericFunctions.ts index 78b03c4f8f..5b70b77f27 100644 --- a/packages/nodes-base/nodes/Aws/Comprehend/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/Comprehend/GenericFunctions.ts @@ -7,6 +7,7 @@ import { IWebhookFunctions, } from 'n8n-core'; + import { IHttpRequestOptions, NodeApiError } from 'n8n-workflow'; export async function awsApiRequest( @@ -31,11 +32,7 @@ export async function awsApiRequest( headers, region: credentials?.region as string, } as IHttpRequestOptions; - try { - return await this.helpers.requestWithAuthentication.call(this, 'aws', requestOptions); - } catch (error) { - throw new NodeApiError(this.getNode(), error); // no XML parsing needed - } + return await this.helpers.requestWithAuthentication.call(this, 'aws', requestOptions); } export async function awsApiRequestREST( diff --git a/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts index b0207c4137..6b17c551eb 100644 --- a/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts @@ -42,11 +42,7 @@ export async function awsApiRequest( if (Object.keys(option).length !== 0) { Object.assign(requestOptions, option); } - try { - return await this.helpers.requestWithAuthentication.call(this, 'aws', requestOptions); - } catch (error) { - throw new NodeApiError(this.getNode(), error); - } + return await this.helpers.requestWithAuthentication.call(this, 'aws', requestOptions); } export async function awsApiRequestREST( diff --git a/packages/nodes-base/nodes/Aws/S3/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/S3/GenericFunctions.ts index 2d5a1405ab..6f3920f4d6 100644 --- a/packages/nodes-base/nodes/Aws/S3/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/S3/GenericFunctions.ts @@ -40,11 +40,7 @@ export async function awsApiRequest( if (Object.keys(option).length !== 0) { Object.assign(requestOptions, option); } - try { - return await this.helpers.requestWithAuthentication.call(this, 'aws', requestOptions); - } catch (error) { - throw new NodeApiError(this.getNode(), error as JsonObject); - } + return await this.helpers.requestWithAuthentication.call(this, 'aws', requestOptions); } export async function awsApiRequestREST( diff --git a/packages/nodes-base/nodes/Beeminder/GenericFunctions.ts b/packages/nodes-base/nodes/Beeminder/GenericFunctions.ts index e88f0de9c2..31d21c180f 100644 --- a/packages/nodes-base/nodes/Beeminder/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Beeminder/GenericFunctions.ts @@ -31,11 +31,7 @@ export async function beeminderApiRequest( delete options.qs; } - try { - return await this.helpers.requestWithAuthentication.call(this, 'beeminderApi', options); - } catch (error) { - throw new NodeApiError(this.getNode(), error); - } + return await this.helpers.requestWithAuthentication.call(this, 'beeminderApi', options); } export async function beeminderApiRequestAllItems( diff --git a/packages/nodes-base/nodes/Calendly/GenericFunctions.ts b/packages/nodes-base/nodes/Calendly/GenericFunctions.ts index 46fd1fc63d..c290566b29 100644 --- a/packages/nodes-base/nodes/Calendly/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Calendly/GenericFunctions.ts @@ -53,11 +53,7 @@ export async function calendlyApiRequest( delete options.qs; } options = Object.assign({}, options, option); - try { - return await this.helpers.requestWithAuthentication.call(this, 'calendlyApi', options); - } catch (error) { - throw new NodeApiError(this.getNode(), error); - } + return await this.helpers.requestWithAuthentication.call(this, 'calendlyApi', options); } export function getAuthenticationType(data: string): 'accessToken' | 'apiKey' { diff --git a/packages/nodes-base/nodes/Clockify/GenericFunctions.ts b/packages/nodes-base/nodes/Clockify/GenericFunctions.ts index 9c4a81def6..ba2bc8bc56 100644 --- a/packages/nodes-base/nodes/Clockify/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Clockify/GenericFunctions.ts @@ -28,12 +28,7 @@ export async function clockifyApiRequest( json: true, useQuerystring: true, }; - - try { - return await this.helpers.requestWithAuthentication.call(this, 'clockifyApi', options); - } catch (error) { - throw new NodeApiError(this.getNode(), error); - } + return await this.helpers.requestWithAuthentication.call(this, 'clockifyApi', options); } export async function clockifyApiRequestAllItems( diff --git a/packages/nodes-base/nodes/Cortex/GenericFunctions.ts b/packages/nodes-base/nodes/Cortex/GenericFunctions.ts index c97ea4f6bc..06297b62b0 100644 --- a/packages/nodes-base/nodes/Cortex/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Cortex/GenericFunctions.ts @@ -42,11 +42,7 @@ export async function cortexApiRequest( delete options.qs; } - try { - return await this.helpers.requestWithAuthentication.call(this, 'cortexApi', options); - } catch (error) { - throw new NodeApiError(this.getNode(), error); - } + return await this.helpers.requestWithAuthentication.call(this, 'cortexApi', options); } export function getEntityLabel(entity: IDataObject): string { diff --git a/packages/nodes-base/nodes/CustomerIo/GenericFunctions.ts b/packages/nodes-base/nodes/CustomerIo/GenericFunctions.ts index 06f70c5090..d1612e969c 100644 --- a/packages/nodes-base/nodes/CustomerIo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/CustomerIo/GenericFunctions.ts @@ -32,11 +32,7 @@ export async function customerIoApiRequest( options.url = `https://beta-api.customer.io/v1/api${endpoint}`; } - try { - return await this.helpers.requestWithAuthentication.call(this, 'customerIoApi', options); - } catch (error) { - throw new NodeApiError(this.getNode(), error); - } + return await this.helpers.requestWithAuthentication.call(this, 'customerIoApi', options); } export function eventExists(currentEvents: string[], webhookEvents: IDataObject) { diff --git a/packages/nodes-base/nodes/Dropcontact/GenericFunction.ts b/packages/nodes-base/nodes/Dropcontact/GenericFunction.ts index 213ed3e9b0..b04fa69c7e 100644 --- a/packages/nodes-base/nodes/Dropcontact/GenericFunction.ts +++ b/packages/nodes-base/nodes/Dropcontact/GenericFunction.ts @@ -30,9 +30,5 @@ export async function dropcontactApiRequest( delete options.qs; } - try { - return await this.helpers.requestWithAuthentication.call(this, 'dropcontactApi', options); - } catch (error) { - throw new NodeApiError(this.getNode(), error); - } + return await this.helpers.requestWithAuthentication.call(this, 'dropcontactApi', options); } diff --git a/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts b/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts index a4dd0ef827..9d9bcf9958 100644 --- a/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts @@ -50,8 +50,7 @@ export async function erpNextApiRequest( message: 'Please ensure the subdomain is correct.', }); } - - throw new NodeApiError(this.getNode(), error); + throw error; } } diff --git a/packages/nodes-base/nodes/Ghost/GenericFunctions.ts b/packages/nodes-base/nodes/Ghost/GenericFunctions.ts index 80bd8814ce..dee8883aa7 100644 --- a/packages/nodes-base/nodes/Ghost/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Ghost/GenericFunctions.ts @@ -44,11 +44,7 @@ export async function ghostApiRequest( json: true, }; - try { - return await this.helpers.requestWithAuthentication.call(this, credentialType, options); - } catch (error) { - throw new NodeApiError(this.getNode(), error as JsonObject); - } + return await this.helpers.requestWithAuthentication.call(this, credentialType, options); } export async function ghostApiRequestAllItems( diff --git a/packages/nodes-base/nodes/HighLevel/GenericFunctions.ts b/packages/nodes-base/nodes/HighLevel/GenericFunctions.ts index c87c4fe334..71c006eefa 100644 --- a/packages/nodes-base/nodes/HighLevel/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HighLevel/GenericFunctions.ts @@ -232,13 +232,7 @@ export async function highLevelApiRequest( delete options.qs; } options = Object.assign({}, options, option); - try { - return await this.helpers.requestWithAuthentication.call(this, 'highLevelApi', options); - } catch (error) { - throw new NodeApiError(this.getNode(), error, { - message: error.message, - }); - } + return await this.helpers.requestWithAuthentication.call(this, 'highLevelApi', options); } export async function getPipelineStages( diff --git a/packages/nodes-base/nodes/Jira/GenericFunctions.ts b/packages/nodes-base/nodes/Jira/GenericFunctions.ts index b99519900d..f42d28d9b0 100644 --- a/packages/nodes-base/nodes/Jira/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Jira/GenericFunctions.ts @@ -58,11 +58,7 @@ export async function jiraSoftwareCloudApiRequest( delete options.qs; } - try { - return await this.helpers.requestWithAuthentication.call(this, credentialType, options); - } catch (error) { - throw new NodeApiError(this.getNode(), error as JsonObject); - } + return await this.helpers.requestWithAuthentication.call(this, credentialType, options); } export async function jiraSoftwareCloudApiRequestAllItems( diff --git a/packages/nodes-base/nodes/Lemlist/GenericFunctions.ts b/packages/nodes-base/nodes/Lemlist/GenericFunctions.ts index c48909c4b4..30a0fa87bd 100644 --- a/packages/nodes-base/nodes/Lemlist/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Lemlist/GenericFunctions.ts @@ -17,10 +17,8 @@ export async function lemlistApiRequest( qs: IDataObject = {}, option: IDataObject = {}, ) { - const options: OptionsWithUri = { - headers: { - }, + headers: {}, method, uri: `https://api.lemlist.com/api${endpoint}`, qs, @@ -40,11 +38,7 @@ export async function lemlistApiRequest( Object.assign(options, option); } - try { - return await this.helpers.requestWithAuthentication.call(this,'lemlistApi',options); - } catch (error) { - throw new NodeApiError(this.getNode(), error); - } + return await this.helpers.requestWithAuthentication.call(this, 'lemlistApi', options); } /** diff --git a/packages/nodes-base/nodes/Mailjet/GenericFunctions.ts b/packages/nodes-base/nodes/Mailjet/GenericFunctions.ts index ad035356da..c1810a0653 100644 --- a/packages/nodes-base/nodes/Mailjet/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mailjet/GenericFunctions.ts @@ -48,11 +48,7 @@ export async function mailjetApiRequest( delete options.body; } - try { - return await this.helpers.requestWithAuthentication.call(this, credentialType, options); - } catch (error) { - throw new NodeApiError(this.getNode(), error as JsonObject); - } + return await this.helpers.requestWithAuthentication.call(this, credentialType, options); } export async function mailjetApiRequestAllItems( diff --git a/packages/nodes-base/nodes/NextCloud/GenericFunctions.ts b/packages/nodes-base/nodes/NextCloud/GenericFunctions.ts index 9f366f22f0..3ddf4fbffb 100644 --- a/packages/nodes-base/nodes/NextCloud/GenericFunctions.ts +++ b/packages/nodes-base/nodes/NextCloud/GenericFunctions.ts @@ -54,10 +54,5 @@ export async function nextCloudApiRequest( const credentialType = authenticationMethod === 'accessToken' ? 'nextCloudApi' : 'nextCloudOAuth2Api'; - - try { - return await this.helpers.requestWithAuthentication.call(this, credentialType, options); - } catch (error) { - throw new NodeApiError(this.getNode(), error as JsonObject); - } + return await this.helpers.requestWithAuthentication.call(this, credentialType, options); } diff --git a/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts b/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts index 5f286b4a78..d28276b8e0 100644 --- a/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts +++ b/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts @@ -61,11 +61,7 @@ export async function apiRequest( delete options.body; } - try { - return await this.helpers.requestWithAuthentication.call(this, authenticationMethod, options); - } catch (error) { - throw new NodeApiError(this.getNode(), error); - } + return await this.helpers.requestWithAuthentication.call(this, authenticationMethod, options); } /** diff --git a/packages/nodes-base/nodes/Rocketchat/GenericFunctions.ts b/packages/nodes-base/nodes/Rocketchat/GenericFunctions.ts index 82471d2b3e..144d41b3aa 100644 --- a/packages/nodes-base/nodes/Rocketchat/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Rocketchat/GenericFunctions.ts @@ -25,11 +25,7 @@ export async function rocketchatApiRequest( if (Object.keys(options.body).length === 0) { delete options.body; } - try { - return await this.helpers.requestWithAuthentication.call(this, 'rocketchatApi', options); - } catch (error) { - throw new NodeApiError(this.getNode(), error); - } + return await this.helpers.requestWithAuthentication.call(this, 'rocketchatApi', options); } // tslint:disable-next-line:no-any diff --git a/packages/nodes-base/nodes/Segment/GenericFunctions.ts b/packages/nodes-base/nodes/Segment/GenericFunctions.ts index 03c1c5c260..1542dc79ba 100644 --- a/packages/nodes-base/nodes/Segment/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Segment/GenericFunctions.ts @@ -36,9 +36,5 @@ export async function segmentApiRequest( if (!Object.keys(body).length) { delete options.body; } - try { - return await this.helpers.requestWithAuthentication.call(this, 'segmentApi', options); - } catch (error) { - throw new NodeApiError(this.getNode(), error); - } + return await this.helpers.requestWithAuthentication.call(this, 'segmentApi', options); } diff --git a/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts b/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts index abd813a29c..a2d63ee95c 100644 --- a/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts @@ -37,11 +37,7 @@ export async function sendGridApiRequest( Object.assign(options, option); } - try { - return await this.helpers.requestWithAuthentication.call(this, 'sendGridApi', options); - } catch (error) { - throw new NodeApiError(this.getNode(), error); - } + return await this.helpers.requestWithAuthentication.call(this, 'sendGridApi', options); } export async function sendGridApiRequestAllItems( diff --git a/packages/nodes-base/nodes/Shopify/GenericFunctions.ts b/packages/nodes-base/nodes/Shopify/GenericFunctions.ts index 74558de796..c4e5190ca7 100644 --- a/packages/nodes-base/nodes/Shopify/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Shopify/GenericFunctions.ts @@ -66,13 +66,9 @@ export async function shopifyApiRequest( delete options.qs; } - try { - return await this.helpers.requestWithAuthentication.call(this, credentialType, options, { - oauth2: oAuth2Options, - }); - } catch (error) { - throw new NodeApiError(this.getNode(), error); - } + return await this.helpers.requestWithAuthentication.call(this, credentialType, options, { + oauth2: oAuth2Options, + }); } export async function shopifyApiRequestAllItems( diff --git a/packages/nodes-base/nodes/Stripe/helpers.ts b/packages/nodes-base/nodes/Stripe/helpers.ts index b7ce635fc1..62b5e118c9 100644 --- a/packages/nodes-base/nodes/Stripe/helpers.ts +++ b/packages/nodes-base/nodes/Stripe/helpers.ts @@ -29,11 +29,7 @@ export async function stripeApiRequest( delete options.qs; } - try { - return await this.helpers.requestWithAuthentication.call(this, 'stripeApi', options); - } catch (error) { - throw new NodeApiError(this.getNode(), error); - } + return await this.helpers.requestWithAuthentication.call(this, 'stripeApi', options); } /** diff --git a/packages/nodes-base/nodes/TheHive/GenericFunctions.ts b/packages/nodes-base/nodes/TheHive/GenericFunctions.ts index e940916a30..bef98392b6 100644 --- a/packages/nodes-base/nodes/TheHive/GenericFunctions.ts +++ b/packages/nodes-base/nodes/TheHive/GenericFunctions.ts @@ -40,11 +40,7 @@ export async function theHiveApiRequest( if (Object.keys(query).length === 0) { delete options.qs; } - try { - return await this.helpers.requestWithAuthentication.call(this, 'theHiveApi', options); - } catch (error) { - throw new NodeApiError(this.getNode(), error); - } + return await this.helpers.requestWithAuthentication.call(this, 'theHiveApi', options); } // Helpers functions diff --git a/packages/nodes-base/nodes/Trello/GenericFunctions.ts b/packages/nodes-base/nodes/Trello/GenericFunctions.ts index 6bb104c913..bcca7871e0 100644 --- a/packages/nodes-base/nodes/Trello/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Trello/GenericFunctions.ts @@ -26,14 +26,7 @@ export async function apiRequest( json: true, }; - try { - return await this.helpers.requestWithAuthentication.call(this, 'trelloApi', options); - } catch (error) { - if (error instanceof NodeApiError) { - throw error; - } - throw new NodeApiError(this.getNode(), error as JsonObject); - } + return await this.helpers.requestWithAuthentication.call(this, 'trelloApi', options); } export async function apiRequestAllItems( diff --git a/packages/nodes-base/nodes/Twake/GenericFunctions.ts b/packages/nodes-base/nodes/Twake/GenericFunctions.ts index 30d46ce2ba..05ee519cb1 100644 --- a/packages/nodes-base/nodes/Twake/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Twake/GenericFunctions.ts @@ -31,12 +31,5 @@ export async function twakeApiRequest( // options.uri = `${credentials!.hostUrl}/api/v1${resource}`; // } - try { - return await this.helpers.requestWithAuthentication.call(this, 'twakeCloudApi', options); - } catch (error) { - if (error.error?.code === 'ECONNREFUSED') { - throw new NodeApiError(this.getNode(), error, { message: 'Twake host is not accessible!' }); - } - throw new NodeApiError(this.getNode(), error); - } + return await this.helpers.requestWithAuthentication.call(this, 'twakeCloudApi', options); } diff --git a/packages/nodes-base/nodes/Twilio/GenericFunctions.ts b/packages/nodes-base/nodes/Twilio/GenericFunctions.ts index 3c335285f3..a19205954c 100644 --- a/packages/nodes-base/nodes/Twilio/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Twilio/GenericFunctions.ts @@ -36,11 +36,7 @@ export async function twilioApiRequest( json: true, }; - try { - return await this.helpers.requestWithAuthentication.call(this, 'twilioApi', options); - } catch (error) { - throw new NodeApiError(this.getNode(), error); - } + return await this.helpers.requestWithAuthentication.call(this, 'twilioApi', options); } const XML_CHAR_MAP: { [key: string]: string } = { diff --git a/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts b/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts index c3352bdf6b..06e2aca6a6 100644 --- a/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts @@ -27,11 +27,7 @@ export async function urlScanIoApiRequest( delete options.qs; } - try { - return await this.helpers.requestWithAuthentication.call(this, 'urlScanIoApi', options); - } catch (error) { - throw new NodeApiError(this.getNode(), error); - } + return await this.helpers.requestWithAuthentication.call(this, 'urlScanIoApi', options); } export async function handleListing( diff --git a/packages/nodes-base/nodes/Webflow/GenericFunctions.ts b/packages/nodes-base/nodes/Webflow/GenericFunctions.ts index aa77597bee..1e3f7b025b 100644 --- a/packages/nodes-base/nodes/Webflow/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Webflow/GenericFunctions.ts @@ -48,11 +48,7 @@ export async function webflowApiRequest( if (Object.keys(options.body).length === 0) { delete options.body; } - try { - return await this.helpers.requestWithAuthentication.call(this, credentialsType, options); - } catch (error) { - throw new NodeApiError(this.getNode(), error); - } + return await this.helpers.requestWithAuthentication.call(this, credentialsType, options); } export async function webflowApiRequestAllItems( diff --git a/packages/nodes-base/nodes/Wekan/GenericFunctions.ts b/packages/nodes-base/nodes/Wekan/GenericFunctions.ts index a181663b9c..8d6a9ccabd 100644 --- a/packages/nodes-base/nodes/Wekan/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Wekan/GenericFunctions.ts @@ -27,12 +27,5 @@ export async function apiRequest( json: true, }; - try { - return await this.helpers.requestWithAuthentication.call(this, 'wekanApi', options); - } catch (error) { - if (error.statusCode === 401) { - throw new NodeOperationError(this.getNode(), 'The Wekan credentials are not valid!'); - } - throw new NodeApiError(this.getNode(), error as JsonObject); - } + return await this.helpers.requestWithAuthentication.call(this, 'wekanApi', options); } diff --git a/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts b/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts index 3ec28cda5f..8258c83040 100644 --- a/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts +++ b/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts @@ -48,11 +48,7 @@ export async function woocommerceApiRequest( delete options.form; } options = Object.assign({}, options, option); - try { - return await this.helpers.requestWithAuthentication.call(this, 'wooCommerceApi', options); - } catch (error) { - throw new NodeApiError(this.getNode(), error); - } + return await this.helpers.requestWithAuthentication.call(this, 'wooCommerceApi', options); } export async function woocommerceApiRequestAllItems( diff --git a/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts b/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts index 6912162bdf..946aec6c6a 100644 --- a/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts @@ -36,9 +36,5 @@ export async function wufooApiRequest( delete options.body; } - try { - return await this.helpers.requestWithAuthentication.call(this, 'wufooApi', options); - } catch (error) { - throw new NodeApiError(this.getNode(), error as JsonObject); - } + return await this.helpers.requestWithAuthentication.call(this, 'wufooApi', options); } diff --git a/packages/nodes-base/nodes/Zendesk/GenericFunctions.ts b/packages/nodes-base/nodes/Zendesk/GenericFunctions.ts index edc4d15fc8..746dbcfe49 100644 --- a/packages/nodes-base/nodes/Zendesk/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zendesk/GenericFunctions.ts @@ -48,11 +48,7 @@ export async function zendeskApiRequest( const credentialType = authenticationMethod === 'apiToken' ? 'zendeskApi' : 'zendeskOAuth2Api'; - try { - return await this.helpers.requestWithAuthentication.call(this, credentialType, options); - } catch (error) { - throw new NodeApiError(this.getNode(), error as JsonObject); - } + return await this.helpers.requestWithAuthentication.call(this, credentialType, options); } /** diff --git a/packages/workflow/src/NodeErrors.ts b/packages/workflow/src/NodeErrors.ts index e405b389af..ceb7fcc5b2 100644 --- a/packages/workflow/src/NodeErrors.ts +++ b/packages/workflow/src/NodeErrors.ts @@ -255,9 +255,12 @@ const STATUS_CODE_MESSAGES: IStatusCodeMessages = { '502': 'Bad gateway - the service failed to handle your request', '503': 'Service unavailable - perhaps try again later?', '504': 'Gateway timed out - perhaps try again later?', + + ECONNREFUSED: 'The service refused the connection - perhaps it is offline', }; const UNKNOWN_ERROR_MESSAGE = 'UNKNOWN ERROR - check the detailed error for more information'; +const UNKNOWN_ERROR_MESSAGE_CRED = 'UNKNOWN ERROR'; interface NodeApiErrorOptions extends NodeOperationErrorOptions { message?: string; @@ -282,10 +285,14 @@ export class NodeApiError extends NodeError { // only for request library error this.removeCircularRefs(error.error as JsonObject); } + // if it's an error generated by axios // look for descriptions in the response object - if (error.isAxiosError && error.response) { - error = error.response as JsonObject; + if (error.reason) { + const reason: IDataObject = error.reason as unknown as IDataObject; + if (reason.isAxiosError && reason.response) { + error = reason.response as JsonObject; + } } if (message) { @@ -351,5 +358,8 @@ export class NodeApiError extends NodeError { default: this.message = UNKNOWN_ERROR_MESSAGE; } + if (this.node.type === 'n8n-nodes-base.noOp' && this.message === UNKNOWN_ERROR_MESSAGE) { + this.message = `${UNKNOWN_ERROR_MESSAGE_CRED} - ${this.httpCode}`; + } } }