EllanJiang/GameFramework · error · GameFrameworkException

Resource group names is invalid.

Error message

Resource group names is invalid.

What it means

ResourceManager.GetResourceGroupCollection(params string[] resourceGroupNames) throws this when the names array is null or has zero entries. A collection requires at least one named resource group to aggregate.

Solutions

  1. Pass at least one valid resource group name
  2. Check array length > 0 before calling
  3. Fix the configuration/parsing step that produced an empty name list

Example fix

// before
string[] names = LoadNames(); // empty
var collection = manager.GetResourceGroupCollection(names);
// after
if (names != null && names.Length > 0)
    var collection = manager.GetResourceGroupCollection(names);
Defensive patterns

Strategy: validation

Validate before calling

if (names == null || names.Length == 0) throw new ArgumentException("At least one resource group name is required", nameof(names));

Type guard

bool IsValidGroupNames(string[] names) => names != null && names.Length > 0 && names.All(n => !string.IsNullOrEmpty(n));

Try / catch

try { var col = manager.GetResourceGroupCollection(names); }
catch (GameFrameworkException ex) when (ex.Message == "Resource group names is invalid.") { log.Error("No resource group names supplied"); }

Prevention

When it happens

Trigger: Calling GetResourceGroupCollection() with no arguments, with a null string[], or with an empty array variable.

Common situations: Building the name list from config that yielded no entries, then spreading it via params; callers passing an array that a parse step returned empty.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15). Data as JSON: /api/errors/b04016147216eb20. Report an issue: GitHub.

Appendix: source

Thrown at GameFramework/Resource/ResourceManager.cs:2182

            }

            results.Clear();
            foreach (KeyValuePair<string, ResourceGroup> resourceGroup in m_ResourceGroups)
            {
                results.Add(resourceGroup.Value);
            }
        }

        /// <summary>
        /// 获取资源组集合。
        /// </summary>
        /// <param name="resourceGroupNames">要获取的资源组名称的集合。</param>
        /// <returns>要获取的资源组集合。</returns>
        public IResourceGroupCollection GetResourceGroupCollection(params string[] resourceGroupNames)
        {
            if (resourceGroupNames == null || resourceGroupNames.Length < 1)
            {
                throw new GameFrameworkException("Resource group names is invalid.");
            }

            ResourceGroup[] resourceGroups = new ResourceGroup[resourceGroupNames.Length];
            for (int i = 0; i < resourceGroupNames.Length; i++)
            {
                if (string.IsNullOrEmpty(resourceGroupNames[i]))
                {
                    throw new GameFrameworkException("Resource group name is invalid.");
                }

                resourceGroups[i] = (ResourceGroup)GetResourceGroup(resourceGroupNames[i]);
                if (resourceGroups[i] == null)
                {
                    throw new GameFrameworkException(Utility.Text.Format("Resource group '{0}' is not exist.", resourceGroupNames[i]));
                }
            }

            return new ResourceGroupCollection(resourceGroups, m_ResourceInfos);

View on GitHub (pinned to d0c010b051)