diff options
| author | Alexandre Flament <alex@al-f.net> | 2020-12-03 10:31:44 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-03 10:31:44 +0100 |
| commit | 89fbb85d454959be725cd4ca19c36c31d05d3289 (patch) | |
| tree | 7ef098d4630c5416aad58f0d3ce5abb27390423f /searx/results.py | |
| parent | 6b5a57882242f24f867b6aa14b79b514720c6d83 (diff) | |
| parent | 64cccae99e625f3ebd879f94797decd0d824608d (diff) | |
Merge pull request #2332 from dalf/metrology-errors
[enh] record exception details per engine
Diffstat (limited to 'searx/results.py')
| -rw-r--r-- | searx/results.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/searx/results.py b/searx/results.py index 46f44e1ad..5bf4e6b9e 100644 --- a/searx/results.py +++ b/searx/results.py @@ -4,6 +4,7 @@ from threading import RLock from urllib.parse import urlparse, unquote from searx import logger from searx.engines import engines +from searx.metrology.error_recorder import record_error CONTENT_LEN_IGNORED_CHARS_REGEX = re.compile(r'[,;:!?\./\\\\ ()-_]', re.M | re.U) @@ -161,6 +162,7 @@ class ResultContainer: def extend(self, engine_name, results): standard_result_count = 0 + error_msgs = set() for result in list(results): result['engine'] = engine_name if 'suggestion' in result: @@ -177,14 +179,21 @@ class ResultContainer: # standard result (url, title, content) if 'url' in result and not isinstance(result['url'], str): logger.debug('result: invalid URL: %s', str(result)) + error_msgs.add('invalid URL') elif 'title' in result and not isinstance(result['title'], str): logger.debug('result: invalid title: %s', str(result)) + error_msgs.add('invalid title') elif 'content' in result and not isinstance(result['content'], str): logger.debug('result: invalid content: %s', str(result)) + error_msgs.add('invalid content') else: self._merge_result(result, standard_result_count + 1) standard_result_count += 1 + if len(error_msgs) > 0: + for msg in error_msgs: + record_error(engine_name, 'some results are invalids: ' + msg) + if engine_name in engines: with RLock(): engines[engine_name].stats['search_count'] += 1 |