Throw an error if the API key is invalid
Code formatting