EllanJiang/GameFramework · error · GameFrameworkException

Resource group name is invalid.

Error message

Resource group name is invalid.

What it means

Inside GetResourceGroupCollection, each element of resourceGroupNames is validated: a null or empty name throws this GameFrameworkException. Every name must be a non-empty identifier of an existing resource group.

Solutions

  1. Remove or fix null/empty entries in the name list before calling
  2. Trim and filter the parsed names: names.Where(n => !string.IsNullOrEmpty(n))
  3. Correct the source config so it contains only valid group names

Example fix

// before
var col = manager.GetResourceGroupCollection("UI", "", "Scene");
// after
var valid = names.Where(n => !string.IsNullOrEmpty(n)).ToArray();
var col = manager.GetResourceGroupCollection(valid);
Defensive patterns

Strategy: validation

Validate before calling

foreach (var n in names)
    if (string.IsNullOrEmpty(n)) throw new ArgumentException("Group name entries must be non-empty");

Type guard

bool AllNamesValid(IEnumerable<string> names) => names != null && names.All(n => !string.IsNullOrWhiteSpace(n));

Try / catch

try { var col = manager.GetResourceGroupCollection(names); }
catch (GameFrameworkException ex) when (ex.Message == "Resource group name is invalid.") { names = names.Where(n => !string.IsNullOrEmpty(n)).ToArray(); /* retry */ }

Prevention

When it happens

Trigger: Calling GetResourceGroupCollection with an array or list containing a null or empty string element, e.g. names containing "" from a split or config entry.

Common situations: Names parsed from a comma-separated config line with stray commas producing empty tokens, or uninitialized array slots.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at GameFramework/Resource/ResourceManager.cs:2190

        /// <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);
        }

        /// <summary>
        /// 获取资源组集合。
        /// </summary>
        /// <param name="resourceGroupNames">要获取的资源组名称的集合。</param>
        /// <returns>要获取的资源组集合。</returns>
        public IResourceGroupCollection GetResourceGroupCollection(List<string> resourceGroupNames)

View on GitHub (pinned to d0c010b051)