import json


def load(filename):
    """Load the configuration file"""

    config = None
    
    # Try to load config
    try:
        fin = open(filename, 'r')
        config = json.load(fin)
    except Exception as e:
        print("Failed to load config file: {}".format(filename))
        print("Please ensure the config file exists and there are no spelling errors.")
        print("To create a config file with default values, run the program again with the --default-config flag.\n")
        raise e
    else:
        fin.close()
    
    return config