Skip to content

Commit

Permalink
Merge pull request #158 from mgalgs/fbtrace-id
Browse files Browse the repository at this point in the history
Add fbtrace_id to FacebookError exception info
  • Loading branch information
jgorset committed May 14, 2017
2 parents 31a07bc + 495e500 commit 91192bf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion facepy/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ class FacepyError(Exception):
class FacebookError(FacepyError):
"""Exception for Facebook errors."""
def __init__(self, message=None, code=None, error_data=None, error_subcode=None,
is_transient=None, error_user_title=None, error_user_msg=None):
is_transient=None, error_user_title=None, error_user_msg=None,
fbtrace_id=None):
self.message = message
self.code = code
self.error_data = error_data
self.error_subcode = error_subcode
self.is_transient = is_transient
self.error_user_title = error_user_title
self.error_user_msg = error_user_msg
self.fbtrace_id = fbtrace_id

if self.code:
message = '[%s] %s' % (self.code, self.message)
Expand Down
3 changes: 2 additions & 1 deletion facepy/graph_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ def _get_url(self, path):
def _get_error_params(self, error_obj):
error_params = {}
error_fields = ['message', 'code', 'error_subcode', 'error_user_msg',
'is_transient', 'error_data', 'error_user_title']
'is_transient', 'error_data', 'error_user_title',
'fbtrace_id']

if 'error' in error_obj:
error_obj = error_obj['error']
Expand Down
3 changes: 2 additions & 1 deletion tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
'error_subcode': 1234567,
'is_transient': False,
'error_user_title': '<error_user_title>',
'error_user_msg': '<error_user_msg>'
'error_user_msg': '<error_user_msg>',
'fbtrace_id': '<fbtrace_id>',
}
}

Expand Down

0 comments on commit 91192bf

Please sign in to comment.