remove BaseException usage

This commit is contained in:
mr-tz
2024-01-31 11:25:32 +01:00
committed by Moritz
parent 75800b9d2e
commit 66c2f07ca8
2 changed files with 4 additions and 8 deletions

View File

@@ -309,9 +309,8 @@ class InvalidAttckOrMbcTechnique(Lint):
with data_path.open("rb") as fd:
self.data = json.load(fd)
self.enabled_frameworks = self.data.keys()
except BaseException:
# If linter-data.json is not present, or if an error happen
# we log an error and lint nothing.
except (FileNotFoundError, json.decoder.JSONDecodeError):
# linter-data.json missing, or JSON error: log an error and skip this lint
logger.warning(
"Could not load 'scripts/linter-data.json'. The att&ck and mbc information will not be linted."
)

View File

@@ -178,11 +178,8 @@ def main(args: argparse.Namespace) -> None:
data["mbc"] = MbcExtractor().run()
logging.info("Writing results to %s", args.output)
try:
with Path(args.output).open("w", encoding="utf-8") as jf:
json.dump(data, jf, indent=2)
except BaseException as e:
logging.error("Exception encountered when writing results: %s", e)
with Path(args.output).open("w", encoding="utf-8") as jf:
json.dump(data, jf, indent=2)
if __name__ == "__main__":