# HG changeset patch # User RhodeCode Admin # Date 2023-08-25 10:50:30 # Node ID e3745ca4b35bbfd8e34be17fdf8abbafbab98e7f # Parent 5fa50ba3daf8580973832e585fc590d3d8216a18 exc-tracking: fixed API calls with new exceptions store engine diff --git a/rhodecode/api/views/server_api.py b/rhodecode/api/views/server_api.py --- a/rhodecode/api/views/server_api.py +++ b/rhodecode/api/views/server_api.py @@ -405,13 +405,19 @@ def store_exception(request, apiuser, ex try: exc_traceback = exc_data['exc_traceback'] exc_type_name = exc_data['exc_type_name'] + exc_value = '' except KeyError as err: - raise JSONRPCError('Missing exc_traceback, or exc_type_name ' - 'in exc_data_json field. Missing: {}'.format(err)) + raise JSONRPCError( + f'Missing exc_traceback, or exc_type_name ' + f'in exc_data_json field. Missing: {err}') + + class ExcType: + __name__ = exc_type_name + + exc_info = (ExcType(), exc_value, exc_traceback) exc_tracking._store_exception( - exc_id=exc_id, exc_traceback=exc_traceback, - exc_type_name=exc_type_name, prefix=prefix) + exc_id=exc_id, exc_info=exc_info, prefix=prefix) exc_url = request.route_url( 'admin_settings_exception_tracker_show', exception_id=exc_id) diff --git a/rhodecode/lib/exc_tracking.py b/rhodecode/lib/exc_tracking.py --- a/rhodecode/lib/exc_tracking.py +++ b/rhodecode/lib/exc_tracking.py @@ -198,14 +198,19 @@ def get_request_metadata(request=None) - return request_metadata -def format_exc(exc_info): +def format_exc(exc_info, use_detailed_tb=True): exc_type, exc_value, exc_traceback = exc_info tb = "++ TRACEBACK ++\n\n" - tb += "".join(traceback.format_exception(exc_type, exc_value, exc_traceback, None)) + if isinstance(exc_traceback, str): + tb += exc_traceback + use_detailed_tb = False + else: + tb += "".join(traceback.format_exception(exc_type, exc_value, exc_traceback, None)) - locals_tb = get_detailed_tb(exc_info) - if locals_tb: - tb += f"\n+++ DETAILS +++\n\n{locals_tb}\n" "" + if use_detailed_tb: + locals_tb = get_detailed_tb(exc_info) + if locals_tb: + tb += f"\n+++ DETAILS +++\n\n{locals_tb}\n" "" return tb