Skip to content

Commit f0e3a37

Browse files
cosimoluporgutzen
andauthored
Correct handling of FileNotFoundError exception for settings file (#107)
* Correct handling of FileNotFoundError for settings file * Update cobrawap/pipeline/utils/snakefile.py Co-authored-by: Robin Gutzen <[email protected]> --------- Co-authored-by: Robin Gutzen <[email protected]>
1 parent f7dccad commit f0e3a37

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

cobrawap/pipeline/utils/snakefile.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
SETTINGS_PATH = Path('~/.cobrawap/config').expanduser()
1212

1313
def get_setting(key: str = None):
14-
with open(SETTINGS_PATH, 'r') as f:
15-
try:
14+
try:
15+
with open(SETTINGS_PATH, 'r') as f:
1616
settings = yaml.load(f)
1717
if not settings:
1818
settings = {}
19-
except Exception as e:
20-
logger.warning(e)
21-
raise FileNotFoundError("The settings file either doesn't exist "\
22-
"or is not in proper JSON format! "\
23-
"Try to run `cobrawap init` to set up the "\
24-
"settings file.")
19+
except Exception as e:
20+
raise FileNotFoundError("The settings file `~/.cobrawap/config` "\
21+
"either does not exist "\
22+
"or is not in proper JSON format! "\
23+
"Try to run `cobrawap init` to set up the "\
24+
"settings file.") from e
2525
if key is None:
2626
return settings
2727
elif key not in settings.keys():

0 commit comments

Comments
 (0)