Skip to content

Commit

Permalink
Swallow known error that happens in add_person_data (#268)
Browse files Browse the repository at this point in the history
* Swallow known error that happens in add_person_data

* clean up commented out other approach
  • Loading branch information
rokob committed Jun 15, 2018
1 parent dc9f062 commit f350bac
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions rollbar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ def _report_exc_info(exc_info, request, extra_data, payload_data, level=None):
if extra_trace_data and not extra_data:
data['custom'] = extra_trace_data

request = _get_actual_request(request)
_add_request_data(data, request)
_add_person_data(data, request)
_add_lambda_context_data(data)
Expand Down Expand Up @@ -741,6 +742,7 @@ def _report_message(message, level, request, extra_data, payload_data):
extra_data = extra_data
data['body']['message'].update(extra_data)

request = _get_actual_request(request)
_add_request_data(data, request)
_add_person_data(data, request)
_add_lambda_context_data(data)
Expand Down Expand Up @@ -1020,6 +1022,15 @@ def _check_add_locals(frame, frame_num, total_frames):
('root' in SETTINGS and (frame.get('filename') or '').lower().startswith((SETTINGS['root'] or '').lower()))))


def _get_actual_request(request):
if WerkzeugLocalProxy and isinstance(request, WerkzeugLocalProxy):
try:
actual_request = request._get_current_object()
except RuntimeError:
return None
return actual_request
return request

def _build_request_data(request):
"""
Returns a dictionary containing data from the request.
Expand All @@ -1042,13 +1053,6 @@ def _build_request_data(request):
if WerkzeugRequest and isinstance(request, WerkzeugRequest):
return _build_werkzeug_request_data(request)

if WerkzeugLocalProxy and isinstance(request, WerkzeugLocalProxy):
try:
actual_request = request._get_current_object()
except RuntimeError:
return None
return _build_werkzeug_request_data(actual_request)

# tornado
if TornadoRequest and isinstance(request, TornadoRequest):
return _build_tornado_request_data(request)
Expand Down

0 comments on commit f350bac

Please sign in to comment.