[Core] Give friendly error when provided instance name doesn't exist. (#2969)

* Update data_manager.py

* Towncrier entry
This commit is contained in:
jack1142 2019-09-28 23:22:45 +02:00 committed by Michael H
parent 6bb1004bcd
commit 80628a28a7
2 changed files with 9 additions and 2 deletions

View File

@ -0,0 +1 @@
Give friendly error when provided instance name doesn't exist.

View File

@ -91,14 +91,20 @@ def load_basic_configuration(instance_name_: str):
try:
with config_file.open(encoding="utf-8") as fs:
config = json.load(fs)
except (FileNotFoundError, KeyError):
except FileNotFoundError:
print(
"You need to configure the bot instance using `redbot-setup`"
" prior to running the bot."
)
sys.exit(1)
else:
try:
basic_config = config[instance_name]
except KeyError:
print(
"Instance with this name doesn't exist."
" You can create new instance using `redbot-setup` prior to running the bot."
)
sys.exit(1)
def _base_data_path() -> Path: