EllanJiang/GameFramework · error · GameFrameworkException

ExpireTime is invalid.

Error message

ExpireTime is invalid.

What it means

ExpireTime controls how long unused objects stay in the pool before auto-release; a negative duration is meaningless, so the ExpireTime setter throws. Valid values are zero or positive seconds (0 meaning no auto-expiry, depending on pool settings).

Solutions

  1. Set ExpireTime to a non-negative float (seconds)
  2. Clamp before assigning: MathF.Max(0f, value)
  3. Fix the config or computation producing the negative duration

Example fix

// before
pool.ExpireTime = config.ExpireSeconds; // -5f from bad config
// after
pool.ExpireTime = Mathf.Max(0f, config.ExpireSeconds);
Defensive patterns

Strategy: validation

Validate before calling

if (expireTime < 0f) expireTime = 0f;
pool.ExpireTime = expireTime;

Type guard

bool IsValidExpireTime(float t) => !float.IsNaN(t) && t >= 0f;

Try / catch

try { pool.ExpireTime = expireTime; }
catch (GameFrameworkException ex) { Log.Error("Invalid ExpireTime {0}", expireTime); }

Prevention

When it happens

Trigger: Assigning objectPool.ExpireTime = -1f, usually from a bad config value, a float parse of a negative setting, or a miscomputed duration (endTime - startTime with inverted operands).

Common situations: Negative values in pool configuration files; unit mistakes (treating the value as milliseconds or computing it from timestamps in the wrong order); serialized fields corrupted by hand-editing.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at GameFramework/ObjectPool/ObjectPoolManager.ObjectPool.cs:158

                    Release();
                }
            }

            /// <summary>
            /// 获取或设置对象池对象过期秒数。
            /// </summary>
            public override float ExpireTime
            {
                get
                {
                    return m_ExpireTime;
                }

                set
                {
                    if (value < 0f)
                    {
                        throw new GameFrameworkException("ExpireTime is invalid.");
                    }

                    if (ExpireTime == value)
                    {
                        return;
                    }

                    m_ExpireTime = value;
                    Release();
                }
            }

            /// <summary>
            /// 获取或设置对象池的优先级。
            /// </summary>
            public override int Priority
            {
                get

View on GitHub (pinned to d0c010b051)