From 833e3b82bcda2889ed87621f52fd3435b6925267 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 3 Aug 2022 14:24:46 -0400 Subject: [PATCH] Island: Crash if deployment cannot be determined --- monkey/monkey_island/cc/services/initialize.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/monkey/monkey_island/cc/services/initialize.py b/monkey/monkey_island/cc/services/initialize.py index cbc4262b2..e83ce4441 100644 --- a/monkey/monkey_island/cc/services/initialize.py +++ b/monkey/monkey_island/cc/services/initialize.py @@ -158,14 +158,13 @@ def _get_depyloyment_from_file(file_path: Path) -> Deployment: with open(file_path, "r") as deployment_info_file: deployment_info = json.load(deployment_info_file) return Deployment[deployment_info["deployment"].upper()] - except FileNotFoundError as ex: - logger.debug(f"Deployment file {file_path} is not found. Exception: {ex}") - except KeyError as ex: - logger.debug(f"Invalid key in the deployment file. Exception: {ex}") - except json.JSONDecodeError as ex: - logger.debug(f"Invalid deployment info file. Exception: {ex}") - except Exception as ex: - logger.debug(f"Couldn't get deployment info from {file_path}. Exception: {ex}.") + except KeyError as err: + raise Exception( + f"The deployment file ({file_path}) did not contain the expected data: " + f"missing key {err}" + ) + except Exception as err: + raise Exception(f"Failed to fetch the deployment from {file_path}: {err}") def _register_services(container: DIContainer):