Skip to content

Commit

Permalink
Fix zeep fault (#568)
Browse files Browse the repository at this point in the history
* Fix for zeep Fault error

* Fix for zeep Fault error

* added zeep error to errors table and moved thing out of try-catch block

* modification in error namings
  • Loading branch information
Hrishabh17 authored May 13, 2024
1 parent 9801581 commit 99a4b63
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
10 changes: 8 additions & 2 deletions apps/mappings/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ def new_fn(workspace_id: int, *args):
except zeep_exceptions.Fault as exception:
error['message'] = 'Zeep Fault error'
error['alert'] = False
error['response'] = exception.__dict__
try:
error['response'] = "{0} {1}".format(exception.message, exception.code)
except Exception:
error['response'] = 'Zeep Fault error'

except NoPrivilegeError as exception:
error['message'] = 'The user has insufficient privilege'
Expand Down Expand Up @@ -124,8 +127,11 @@ def new_fn(expense_attribute_instance, *args):
except zeep_exceptions.Fault as exception:
error['message'] = 'Zeep Fault error'
error['alert'] = False
error['response'] = exception.__dict__
import_log.status = 'FAILED'
try:
error['response'] = "{0} {1}".format(exception.message, exception.code)
except Exception:
error['response'] = 'Zeep Fault error'

except NoPrivilegeError as exception:
error['message'] = 'The user has insufficient privilege'
Expand Down
24 changes: 21 additions & 3 deletions apps/netsuite/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,31 @@ def wrapper(*args):
update_failed_expenses(expense_group.expenses.all(), False)

except zeep_exceptions.Fault as exception:
logger.info('Error while exporting: %s', exception.__dict__)
detail = json.dumps(exception.__dict__)
detail = json.loads(detail)
task_log.status = 'FAILED'
detail = 'Zeep Fault error'
logger.info(f'Error while exporting: {exception.__dict__}')
try:
detail = "{0} {1}".format(exception.message, exception.code)
logger.info(f'Error while exporting: {detail}')
except Exception:
logger.info(f'Error while exporting: {detail}')

task_log.detail = detail
task_log.save()

error, created = Error.objects.update_or_create(
workspace_id=workspace_id,
expense_group=expense_group,
defaults={
'type': 'NETSUITE_ERROR',
'error_title': 'Something unexpected has happened during export',
'error_detail': f'{detail}, workspace_id - {workspace_id}',
'repetition_count': F('repetition_count') + 1,
'is_resolved': False
}
)
error.increase_repetition_count_by_one(created)

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

0 comments on commit 99a4b63

Please sign in to comment.