Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added RetryException handler and bumped the sdk versions #306

Merged
merged 2 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@

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()

Check warning on line 157 in apps/fyle/tasks.py

View check run for this annotation

Codecov / codecov/patch

apps/fyle/tasks.py#L154-L157

Added lines #L154 - L157 were not covered by tests

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 @@
error["response"] = exception.response
error["alert"] = True

except RetryException as exception:
error["message"] = "Retry exception"
error["response"] = exception.__dict__

Check warning on line 48 in apps/mappings/exceptions.py

View check run for this annotation

Codecov / codecov/patch

apps/mappings/exceptions.py#L47-L48

Added lines #L47 - L48 were not covered by tests

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
Loading