Skip to content

Commit a17d723

Browse files
committed
utils/fuzzy.py: Add exception logging
Signed-off-by: Filip Gołaś <[email protected]>
1 parent d18d738 commit a17d723

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/robot/utils/fuzzy.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
import fuzzysearch
3+
from robot.api import logger
34

45
def fuzzy_find(buffer, expected, percent_match=None, max_errors=None, max_insertions:int=None, max_deletions:int=None, ignore_case=False):
56
found = fuzzy_find_all(buffer, expected, percent_match, max_errors, max_insertions, max_deletions, ignore_case)
@@ -25,12 +26,17 @@ def fuzzy_find_all(buffer, expected, percent_match:float=None, max_errors:int=No
2526
else:
2627
max_l_dist = None
2728

28-
29-
if ignore_case:
30-
matches = fuzzysearch.find_near_matches(expected.lower(), buffer.lower(), max_l_dist=max_l_dist, max_insertions=max_insertions, max_deletions=max_deletions)
31-
# change matched to contain original, possibly uppercase, input
32-
for match in matches:
33-
match.matched = buffer[match.start:match.end]
34-
else:
35-
matches = fuzzysearch.find_near_matches(expected, buffer, max_l_dist=max_l_dist, max_insertions=max_insertions, max_deletions=max_deletions)
29+
try:
30+
if ignore_case:
31+
matches = fuzzysearch.find_near_matches(expected.lower(), buffer.lower(), max_l_dist=max_l_dist, max_insertions=max_insertions, max_deletions=max_deletions)
32+
# change matched to contain original, possibly uppercase, input
33+
for match in matches:
34+
match.matched = buffer[match.start:match.end]
35+
else:
36+
matches = fuzzysearch.find_near_matches(expected, buffer, max_l_dist=max_l_dist, max_insertions=max_insertions, max_deletions=max_deletions)
37+
except Exception as e:
38+
logger.error(e)
39+
logger.error("\n\n\nbuffer:")
40+
logger.error(buffer)
41+
logger.error("\n\n\nexpected:")
3642
return matches

0 commit comments

Comments
 (0)