-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into import-vendors-as-merchants
- Loading branch information
Showing
44 changed files
with
1,322 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import logging | ||
import traceback | ||
from functools import wraps | ||
|
||
from fyle.platform.exceptions import NoPrivilegeError | ||
|
||
from apps.workspaces.models import FyleCredential | ||
|
||
logger = logging.getLogger(__name__) | ||
logger.level = logging.INFO | ||
|
||
|
||
def handle_exceptions(func): | ||
@wraps(func) | ||
def wrapper(*args, **kwargs): | ||
try: | ||
return func(*args, **kwargs) | ||
except FyleCredential.DoesNotExist: | ||
logger.info('Fyle credentials not found %s', args[1]) # args[1] is workspace_id | ||
args[2].detail = {'message': 'Fyle credentials do not exist in workspace'} | ||
args[2].status = 'FAILED' | ||
args[2].save() | ||
|
||
except NoPrivilegeError: | ||
logger.info('Invalid Fyle Credentials / Admin is disabled') | ||
args[2].detail = {'message': 'Invalid Fyle Credentials / Admin is disabled'} | ||
args[2].status = 'FAILED' | ||
args[2].save() | ||
|
||
except Exception: | ||
error = traceback.format_exc() | ||
args[2].detail = {'error': error} | ||
args[2].status = 'FATAL' | ||
args[2].save() | ||
logger.exception('Something unexpected happened workspace_id: %s %s', args[1], args[2].detail) | ||
|
||
return wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.