Skip to content

Commit

Permalink
TASK: Surround external method with try catch
Browse files Browse the repository at this point in the history
This is done because this code is likely to fail, since it's external. Better to handle that correctly.
  • Loading branch information
d-Rickyy-b committed Jan 12, 2019
1 parent ae6055e commit ef76604
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pastepwn/analyzers/genericanalyzer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
import logging

from .basicanalyzer import BasicAnalyzer


Expand All @@ -16,4 +18,10 @@ def __init__(self, actions, match_func):

def match(self, paste):
"""Run the passed function and return its return value"""
return self.match_func(paste)
try:
result = self.match_func(paste)
except Exception as e:
result = False
logging.getLogger(__name__).warning("Executing custom match function raised an exception! {}".format(e))

return result

0 comments on commit ef76604

Please sign in to comment.