Skip to content

Commit

Permalink
Added RetryException handler and bumped the sdk versions (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hrishabh17 authored Feb 29, 2024
1 parent 3d4d073 commit 1554bf5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
12 changes: 11 additions & 1 deletion apps/fyle/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down
12 changes: 11 additions & 1 deletion apps/mappings/exceptions.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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__
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1554bf5

Please sign in to comment.