[fix] error_recorder: record code and lineno about the engine

since the PR #2225 , code and lineno were sometimes meaningless
see /stats/errors
This commit is contained in:
Alexandre Flament 2021-01-17 16:11:26 +01:00
parent 80d7411f2c
commit ca76f3119a

View File

@ -51,15 +51,12 @@ def add_error_context(engine_name: str, error_context: ErrorContext) -> None:
def get_trace(traces): def get_trace(traces):
previous_trace = traces[-1]
for trace in reversed(traces): for trace in reversed(traces):
if trace.filename.endswith('searx/search.py'): split_filename = trace.filename.split('/')
if previous_trace.filename.endswith('searx/poolrequests.py'): if len(split_filename) > 3 and '/'.join(split_filename[-3:-1]) == 'searx/engines':
return trace return trace
if previous_trace.filename.endswith('requests/models.py'): if len(split_filename) > 3 and '/'.join(split_filename[-4:-1]) == 'searx/search/processors':
return trace return trace
return previous_trace
previous_trace = trace
return traces[-1] return traces[-1]