From 1554bf500884d945787dca3d9f6082b6e39be11f Mon Sep 17 00:00:00 2001 From: Hrishabh Tiwari <74908943+Hrishabh17@users.noreply.github.com> Date: Thu, 29 Feb 2024 19:32:30 +0530 Subject: [PATCH] Added RetryException handler and bumped the sdk versions (#306) --- apps/fyle/tasks.py | 12 +++++++++++- apps/mappings/exceptions.py | 12 +++++++++++- requirements.txt | 4 ++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/apps/fyle/tasks.py b/apps/fyle/tasks.py index fb453002..10d9eeb3 100644 --- a/apps/fyle/tasks.py +++ b/apps/fyle/tasks.py @@ -4,7 +4,10 @@ from typing import Dict, List from django.db import transaction -from fyle.platform.exceptions import InvalidTokenError as FyleInvalidTokenError +from fyle.platform.exceptions import ( + InvalidTokenError as FyleInvalidTokenError, + RetryException, +) from fyle_integrations_platform_connector import PlatformConnector from apps.fyle.actions import create_generator_and_post_in_batches @@ -146,6 +149,13 @@ def async_create_expense_groups( except FyleInvalidTokenError: logger.info("Invalid Token for Fyle") + + except RetryException: + logger.info("Fyle Retry Exception occured in workspace_id: %s", workspace_id) + task_log.detail = {"message": "Fyle Retry Exception"} + task_log.status = TaskLogStatusEnum.FATAL + task_log.save() + except Exception: error = traceback.format_exc() task_log.detail = {"error": error} diff --git a/apps/mappings/exceptions.py b/apps/mappings/exceptions.py index b50c8ed0..0aea5606 100644 --- a/apps/mappings/exceptions.py +++ b/apps/mappings/exceptions.py @@ -1,7 +1,13 @@ import logging import traceback -from fyle.platform.exceptions import InternalServerError, InvalidTokenError, PlatformError, WrongParamsError +from fyle.platform.exceptions import ( + InternalServerError, + InvalidTokenError, + PlatformError, + WrongParamsError, + RetryException +) from xerosdk.exceptions import InvalidGrant from xerosdk.exceptions import InvalidTokenError as XeroInvalidTokenError from xerosdk.exceptions import UnsuccessfulAuthentication @@ -37,6 +43,10 @@ def new_fn(workspace_id, *args): error["response"] = exception.response error["alert"] = True + except RetryException as exception: + error["message"] = "Retry exception" + error["response"] = exception.__dict__ + except InternalServerError as exception: error["message"] = "Internal server error while importing to Fyle" error["response"] = exception.__dict__ diff --git a/requirements.txt b/requirements.txt index f4733222..19e740d3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,9 +17,9 @@ djangorestframework==3.11.2 django-sendgrid-v5==1.2.0 enum34==1.1.10 future==0.18.2 -fyle==0.35.0 +fyle==0.36.1 fyle-accounting-mappings==1.26.2 -fyle-integrations-platform-connector==1.36.1 +fyle-integrations-platform-connector==1.36.3 fyle-rest-auth==1.7.0 gevent==23.9.1 gunicorn==20.1.0