Improve error handling when loading configuration