From 07a3dbb37249667d4837663d009a54a9db2332c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Tue, 22 Jun 2021 19:59:27 +0200 Subject: [PATCH] :zap: Add status code for service account error (#1707) --- packages/nodes-base/nodes/Google/Books/GenericFunctions.ts | 4 ++++ packages/nodes-base/nodes/Google/Drive/GenericFunctions.ts | 4 ++++ packages/nodes-base/nodes/Google/Gmail/GenericFunctions.ts | 4 ++++ packages/nodes-base/nodes/Google/Sheet/GenericFunctions.ts | 6 +++++- packages/nodes-base/nodes/Google/Slides/GenericFunctions.ts | 4 ++++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts index ac299b726..b05c17f4b 100644 --- a/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts @@ -53,6 +53,10 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF return await this.helpers.requestOAuth2.call(this, 'googleBooksOAuth2Api', options); } } catch (error) { + if (error.code === 'ERR_OSSL_PEM_NO_START_LINE') { + error.statusCode = '401'; + } + throw new NodeApiError(this.getNode(), error); } } diff --git a/packages/nodes-base/nodes/Google/Drive/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Drive/GenericFunctions.ts index 9d8a0ff13..e48779ddc 100644 --- a/packages/nodes-base/nodes/Google/Drive/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Drive/GenericFunctions.ts @@ -51,6 +51,10 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF return await this.helpers.requestOAuth2.call(this, 'googleDriveOAuth2Api', options); } } catch (error) { + if (error.code === 'ERR_OSSL_PEM_NO_START_LINE') { + error.statusCode = '401'; + } + throw new NodeApiError(this.getNode(), error); } } diff --git a/packages/nodes-base/nodes/Google/Gmail/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Gmail/GenericFunctions.ts index 1507eb520..778f6ea2f 100644 --- a/packages/nodes-base/nodes/Google/Gmail/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Gmail/GenericFunctions.ts @@ -74,6 +74,10 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF } } catch (error) { + if (error.code === 'ERR_OSSL_PEM_NO_START_LINE') { + error.statusCode = '401'; + } + throw new NodeApiError(this.getNode(), error); } } diff --git a/packages/nodes-base/nodes/Google/Sheet/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Sheet/GenericFunctions.ts index 91db4df18..1e6f03e98 100644 --- a/packages/nodes-base/nodes/Google/Sheet/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Sheet/GenericFunctions.ts @@ -53,6 +53,10 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF return await this.helpers.requestOAuth2.call(this, 'googleSheetsOAuth2Api', options); } } catch (error) { + if (error.code === 'ERR_OSSL_PEM_NO_START_LINE') { + error.statusCode = '401'; + } + throw new NodeApiError(this.getNode(), error); } } @@ -138,4 +142,4 @@ export function hexToRgb(hex: string) { green: parseInt(result[2], 16), blue: parseInt(result[3], 16), } : null; -} \ No newline at end of file +} diff --git a/packages/nodes-base/nodes/Google/Slides/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Slides/GenericFunctions.ts index c58057003..647db06dc 100644 --- a/packages/nodes-base/nodes/Google/Slides/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Slides/GenericFunctions.ts @@ -54,6 +54,10 @@ export async function googleApiRequest( return await this.helpers.requestOAuth2!.call(this, 'googleSlidesOAuth2Api', options); } } catch (error) { + if (error.code === 'ERR_OSSL_PEM_NO_START_LINE') { + error.statusCode = '401'; + } + throw new NodeApiError(this.getNode(), error); } }