Skip to content

Commit

Permalink
Added RetryException handler and bumped the sdk versions (#567)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hrishabh17 authored Feb 14, 2024
1 parent eeee57e commit 7451d1a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
11 changes: 10 additions & 1 deletion apps/fyle/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,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, mark_expenses_as_skipped
Expand Down Expand Up @@ -148,6 +151,12 @@ def async_create_expense_groups(workspace_id: int, fund_source: List[str], task_
task_log.status = 'FAILED'
task_log.save()

except RetryException:
logger.info('Fyle Retry Exception occured in workspace_id %s', workspace_id)
task_log.detail = {'message': 'Retrying task'}
task_log.status = 'FATAL'
task_log.save()

except Exception:
handle_import_exception(task_log)

Expand Down
10 changes: 9 additions & 1 deletion apps/mappings/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import logging
import traceback

from fyle.platform.exceptions import InternalServerError, InvalidTokenError, WrongParamsError
from fyle.platform.exceptions import (
InternalServerError,
InvalidTokenError,
WrongParamsError,
RetryException
)
from qbosdk.exceptions import InvalidTokenError as QBOInvalidTokenError
from qbosdk.exceptions import WrongParamsError as QBOWrongParamsError

Expand Down Expand Up @@ -29,6 +34,9 @@ def new_fn(workspace_id: int, *args):
error['response'] = exception.response
error['alert'] = True

except RetryException:
error['message'] = 'Retrying task'

except InternalServerError as exception:
error['message'] = 'Internal server error while importing to Fyle'
error['response'] = exception.__dict__
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ django-sendgrid-v5==1.2.0
enum34==1.1.10
future==0.18.2
fyle-accounting-mappings==1.26.1
fyle-integrations-platform-connector==1.36.2
fyle-integrations-platform-connector==1.36.3
fyle-rest-auth==1.6.0
flake8==4.0.1
gevent==23.9.1
Expand Down

0 comments on commit 7451d1a

Please sign in to comment.