Skip to content

Commit

Permalink
Catch errors when dsh has not been initialised
Browse files Browse the repository at this point in the history
  • Loading branch information
craddm committed Oct 2, 2023
1 parent 0eea359 commit 283f0e9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions data_safe_haven/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from yaml.parser import ParserError

from data_safe_haven import __version__
from data_safe_haven.exceptions import DataSafeHavenAzureError, DataSafeHavenConfigError
from data_safe_haven.exceptions import DataSafeHavenAzureError, DataSafeHavenConfigError, DataSafeHavenParameterError
from data_safe_haven.external import AzureApi
from data_safe_haven.functions import (
alphanumeric,
Expand Down Expand Up @@ -352,7 +352,12 @@ def __init__(self) -> None:
self.sres: dict[str, ConfigSectionSRE] = defaultdict(ConfigSectionSRE)
# Read backend settings
settings = BackendSettings()
self.name = settings.name
# Check if backend exists and was loaded
try:
self.name = settings.name
except DataSafeHavenParameterError as exc:
msg = f"Data Safe Haven has not been initialised: run '[bright_cyan]dsh init[/]' before continuing."
raise DataSafeHavenConfigError(msg) from exc
self.subscription_name = settings.subscription_name
self.azure.location = settings.location
self.azure.admin_group_id = settings.admin_group_id
Expand Down

0 comments on commit 283f0e9

Please sign in to comment.