From 359a8f3f0896c1454585f160b32eee0460785ecc Mon Sep 17 00:00:00 2001 From: Sai Sankeerth Date: Thu, 29 Aug 2024 20:44:34 +0530 Subject: [PATCH] chore: handle other error use-cases in reddit --- src/v0/destinations/reddit/networkHandler.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/v0/destinations/reddit/networkHandler.js b/src/v0/destinations/reddit/networkHandler.js index 2da56a06a8..7c9b32eaa4 100644 --- a/src/v0/destinations/reddit/networkHandler.js +++ b/src/v0/destinations/reddit/networkHandler.js @@ -1,11 +1,13 @@ -const { RetryableError } = require('@rudderstack/integrations-lib'); +const { RetryableError, TAG_NAMES, NetworkError } = require('@rudderstack/integrations-lib'); const isString = require('lodash/isString'); const { prepareProxyRequest, proxyRequest } = require('../../../adapters/network'); const { isHttpStatusSuccess } = require('../../util/index'); const { REFRESH_TOKEN } = require('../../../adapters/networkhandler/authConstants'); -const logger = require('../../../logger'); -const { processAxiosResponse } = require('../../../adapters/utils/networkUtils'); +const { + processAxiosResponse, + getDynamicErrorType, +} = require('../../../adapters/utils/networkUtils'); const redditRespHandler = (destResponse) => { const { status, response } = destResponse; @@ -30,7 +32,14 @@ const redditRespHandler = (destResponse) => { authErrorCategory, ); } - logger.error(`Error in Reddit response transformation: ${JSON.stringify(destResponse)}`); + throw new NetworkError( + `${JSON.stringify(response)} during reddit response transformation`, + status, + { + [TAG_NAMES.ERROR_TYPE]: getDynamicErrorType(status), + }, + destResponse, + ); }; const responseHandler = (responseParams) => { const { destinationResponse } = responseParams;