diff --git a/slither/tools/mutator/mutators/abstract_mutator.py b/slither/tools/mutator/mutators/abstract_mutator.py index 2e99466d9..21ce52ebe 100644 --- a/slither/tools/mutator/mutators/abstract_mutator.py +++ b/slither/tools/mutator/mutators/abstract_mutator.py @@ -6,6 +6,7 @@ from slither.formatters.utils.patches import apply_patch, create_diff from slither.tools.mutator.utils.testing_generated_mutant import test_patch from slither.core.declarations import Contract +from slither.utils.colors import red logger = logging.getLogger("Slither-Mutate") @@ -70,13 +71,17 @@ def __init__( # pylint: disable=too-many-arguments @abc.abstractmethod def _mutate(self) -> Dict: - """TODO Documentation""" + """Abstract placeholder, will be overwritten by each mutator""" return {} # pylint: disable=too-many-branches def mutate(self) -> Tuple[List[int], List[int], List[int]]: - # call _mutate function from different mutators - (all_patches) = self._mutate() + all_patches: Dict = {} + try: + # call _mutate function from different mutators + (all_patches) = self._mutate() + except Exception as e: + logger.error(red("%s mutator failed in %s: %s"), self.NAME, self.contract.name, str(e)) if "patches" not in all_patches: logger.debug("No patches found by %s", self.NAME) return [0, 0, 0], [0, 0, 0], self.dont_mutate_line diff --git a/slither/tools/mutator/utils/testing_generated_mutant.py b/slither/tools/mutator/utils/testing_generated_mutant.py index d484ff68f..d5725485b 100644 --- a/slither/tools/mutator/utils/testing_generated_mutant.py +++ b/slither/tools/mutator/utils/testing_generated_mutant.py @@ -109,9 +109,7 @@ def test_patch( # pylint: disable=too-many-arguments create_mutant_file(output_folder, file, generator_name) logger.info( - red( - f"[{generator_name}] Line {patch['line_number']}: '{patch['old_string']}' ==> '{patch['new_string']}' --> UNCAUGHT" - ) + f"[{generator_name}] Line {patch['line_number']}: '{patch['old_string']}' ==> '{patch['new_string']}' --> UNCAUGHT" ) reset_file(file)