Removed duplication in get_api_errors method.