diff options
| author | onur-ozkan <work@onurozkan.dev> | 2023-11-26 18:37:59 +0300 |
|---|---|---|
| committer | onur-ozkan <work@onurozkan.dev> | 2023-11-26 19:05:02 +0300 |
| commit | 101704257533adb2e700cb6f12b12e2e0de8b9af (patch) | |
| tree | f558bd25894934b47dd0cad98c645ee5c3e126a4 /src/bootstrap/bootstrap.py | |
| parent | 42ae1a76154289ccc972deeb43318b164f01539e (diff) | |
| download | rust-101704257533adb2e700cb6f12b12e2e0de8b9af.tar.gz rust-101704257533adb2e700cb6f12b12e2e0de8b9af.zip | |
give dev-friendly error message for incorrect config profiles
before this change, an incorrect profile would result in the following error:
```sh
...
...
File "/home/nimda/devspace/onur-ozkan/rust/src/bootstrap/bootstrap.py", line 1088, in bootstrap
with open(include_path) as included_toml:
^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/home/nimda/devspace/onur-ozkan/rust/src/bootstrap/defaults/config.aaaa.toml'
```
with this change, the error message is now:
```sh
...
...
File "/home/nimda/devspace/onur-ozkan/rust/src/bootstrap/bootstrap.py", line 1088, in bootstrap
raise Exception("Unrecognized profile '{}'. Check src/bootstrap/defaults"
Exception: Unrecognized profile 'aaaa'. Check src/bootstrap/defaults for available options.
```
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Diffstat (limited to 'src/bootstrap/bootstrap.py')
| -rw-r--r-- | src/bootstrap/bootstrap.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 5a84e37f8cf..4691fb3ad6f 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -1083,6 +1083,11 @@ def bootstrap(args): include_file = 'config.{}.toml'.format(profile_aliases.get(profile) or profile) include_dir = os.path.join(rust_root, 'src', 'bootstrap', 'defaults') include_path = os.path.join(include_dir, include_file) + + if not os.path.exists(include_path): + raise Exception("Unrecognized config profile '{}'. Check src/bootstrap/defaults" + " for available options.".format(profile)) + # HACK: This works because `self.get_toml()` returns the first match it finds for a # specific key, so appending our defaults at the end allows the user to override them with open(include_path) as included_toml: |
