Skip to content

SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.

sflib: remove raise exception in error() function

Brendan Coles2b4108b7d6e0
diff --git a/sflib.py b/sflib.py
index 7282403e..c634c146 100644
--- a/sflib.py
+++ b/sflib.py
@@ -427,7 +427,7 @@ class SpiderFoot:
return self.dbh.scanLogEvent(self.scanId, level, message, component)
- def error(self, message, exception=True):
+ def error(self, message, exception=False):
"""Print an error message and optionally also raise an exception.
Args:
@@ -444,11 +444,7 @@ class SpiderFoot:
if self.dbh:
self._dblog("ERROR", message)
- if exception:
- self.log.exception(message)
- raise BaseException(f"Internal Error Encountered: {message}")
- else:
- self.log.error(message)
+ self.log.error(message)
def fatal(self, error):
"""Print an error message and stacktrace then exit.
diff --git a/sfscan.py b/sfscan.py
index 12e7f48d..edb74616 100644
--- a/sfscan.py
+++ b/sfscan.py
@@ -247,7 +247,7 @@ class SpiderFootScanner():
try:
module = __import__('modules.' + modName, globals(), locals(), [modName])
except ImportError:
- self.__sf.error("Failed to load module: " + modName, False)
+ self.__sf.error(f"Failed to load module: {modName}")
continue
mod = getattr(module, modName)()
@@ -350,7 +350,7 @@ class SpiderFootScanner():
exc_type, exc_value, exc_traceback = sys.exc_info()
self.__sf.error(f"Unhandled exception ({e.__class__.__name__}) encountered during scan."
+ "Please report this as a bug: "
- + repr(traceback.format_exception(exc_type, exc_value, exc_traceback)), False)
+ + repr(traceback.format_exception(exc_type, exc_value, exc_traceback)))
self.__sf.status(f"Scan [{self.__scanId}] failed: {e}")
self.__setStatus("ERROR-FAILED", None, time.time() * 1000)
diff --git a/test/unit/test_spiderfoot.py b/test/unit/test_spiderfoot.py
index 8a526e6a..0fe3ed52 100644
--- a/test/unit/test_spiderfoot.py
+++ b/test/unit/test_spiderfoot.py
@@ -188,16 +188,13 @@ class TestSpiderFoot(unittest.TestCase):
def test_error(self):
"""
- Test error(self, error, exception=True)
+ Test error(self, error, exception=False)
"""
sf = SpiderFoot(self.default_options)
sf.error(None, exception=False)
self.assertEqual('TBD', 'TBD')
- with self.assertRaises(BaseException):
- sf.error(None, exception=True)
-
def test_fatal_should_exit(self):
"""
Test fatal(self, error)