Better error handling for APIKey