Skip to content

Commit

Permalink
Handle token expire exceptions during payments sync (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwin1111 authored Jan 3, 2023
1 parent b48f976 commit d897ba3
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions apps/xero/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,33 @@ def create_payment(workspace_id):

task_log.save()

except NoPrivilegeError as exception:
xero_credentials = XeroCredentials.objects.filter(workspace_id=workspace_id).first()
xero_credentials.refresh_token = None
xero_credentials.country = None
xero_credentials.is_expired = True
xero_credentials.save()
logger.error(exception.message)
task_log.status = 'FAILED'
task_log.detail = None
task_log.xero_errors = [
{
'error': {
'Elements': [
{
'ValidationErrors': [
{
'Message': 'Xero account got disconnected, please go Configurations -> Tenant page and connect to Xero again'
}
]
}
]
}
}
]

task_log.save()

except Exception:
error = traceback.format_exc()
task_log.detail = {
Expand Down

0 comments on commit d897ba3

Please sign in to comment.