Notify if config file is missing#340
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR improves error handling in the load_config function by adding an explicit check for config file existence, raising a COMPASSValueError with a clear message when the file does not exist. This helps speed up the debugging process by providing immediate feedback instead of potentially less clear errors from attempting to open a non-existent file.
Key Changes:
- Added file existence validation in
load_configfunction before attempting to read the config file - Raises
COMPASSValueErrorwith a descriptive message when the config file is missing
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if not config_fp.exists(): | ||
| msg = f"Config file does not exist: {config_fp}" | ||
| raise COMPASSValueError(msg) |
There was a problem hiding this comment.
The docstring's "Raises" section should be updated to document the new error condition. It currently only mentions the case when the config file doesn't end with .json or .json5, but it should also mention that COMPASSValueError is raised when the config file does not exist.
ppinchuk
left a comment
There was a problem hiding this comment.
Thanks for this!!
I'm really surprised that config_fp.open didn't raise a similar error. Actually maybe it did, but it wasn't captured by our logs. Throwing a COMPASSValueError will add the error to our logs, so this should be a good workaround.
Just notify that the requested config file does not exist to speed up debugging process.