{"record":{"id":"85e4059f2a2dc942","repo":"EllanJiang/GameFramework","slug":"update-resources-complete-callback-is-invalid","errorCode":null,"errorMessage":"Update resources complete callback is invalid.","messagePattern":"Update resources complete callback is invalid\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.cs","lineNumber":1301,"sourceCode":"        /// <summary>\n        /// 使用可更新模式并更新所有资源。\n        /// </summary>\n        /// <param name=\"updateResourcesCompleteCallback\">使用可更新模式并更新默认资源组完成时的回调函数。</param>\n        public void UpdateResources(UpdateResourcesCompleteCallback updateResourcesCompleteCallback)\n        {\n            UpdateResources(string.Empty, updateResourcesCompleteCallback);\n        }\n\n        /// <summary>\n        /// 使用可更新模式并更新指定资源组的资源。\n        /// </summary>\n        /// <param name=\"resourceGroupName\">要更新的资源组名称。</param>\n        /// <param name=\"updateResourcesCompleteCallback\">使用可更新模式并更新指定资源组完成时的回调函数。</param>\n        public void UpdateResources(string resourceGroupName, UpdateResourcesCompleteCallback updateResourcesCompleteCallback)\n        {\n            if (updateResourcesCompleteCallback == null)\n            {\n                throw new GameFrameworkException(\"Update resources complete callback is invalid.\");\n            }\n\n            if (m_ResourceMode == ResourceMode.Unspecified)\n            {\n                throw new GameFrameworkException(\"You must set resource mode first.\");\n            }\n\n            if (m_ResourceMode != ResourceMode.Updatable && m_ResourceMode != ResourceMode.UpdatableWhilePlaying)\n            {\n                throw new GameFrameworkException(\"You can not use UpdateResources without updatable resource mode.\");\n            }\n\n            if (m_ResourceUpdater == null)\n            {\n                throw new GameFrameworkException(\"You can not use UpdateResources at this time.\");\n            }\n\n            ResourceGroup resourceGroup = (ResourceGroup)GetResourceGroup(resourceGroupName);","sourceCodeStart":1283,"sourceCodeEnd":1319,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.cs#L1283-L1319","documentation":"This GameFrameworkException is thrown by ResourceManager.UpdateResources when updateResourcesCompleteCallback is null. The manager requires a completion callback to report when the resource group update finishes or fails, so it fails fast instead of starting an update that could never report its result. It is argument validation.","triggerScenarios":"Calling UpdateResources(resourceGroupName, null); passing an uninitialized delegate field; refactors that removed the callback argument value.","commonSituations":"Hot-update code where the completion handler is conditionally assigned; wiring errors in custom update UI; unit tests calling the API without a handler.","solutions":["Pass a non-null UpdateResourcesCompleteCallback to UpdateResources.","Initialize the callback field before invoking the update flow.","Handle the completion (and any nested error reporting) in the provided callback rather than omitting it."],"exampleFix":"// before\nresourceManager.UpdateResources(\"MyGroup\", null);\n// after\nresourceManager.UpdateResources(\"MyGroup\", (group, success) => {\n    UnityEngine.Debug.LogFormat(\"Update resource group '{0}' {1}.\", group, success ? \"complete\" : \"failed\");\n});","handlingStrategy":"validation","validationCode":"if (updateCallback == null) throw new ArgumentNullException(nameof(updateCallback));\nresourceManager.UpdateResources(groupName, updateCallback);","typeGuard":"bool HasCallback(UpdateResourcesCompleteCallback cb) => cb != null;","tryCatchPattern":"try { resourceManager.UpdateResources(groupName, callback); }\ncatch (GameFrameworkException ex) { UnityEngine.Debug.LogError($\"UpdateResources failed: {ex.Message}\"); }","preventionTips":["Always pass a completion callback to UpdateResources.","Keep callback assignment in one place so it cannot be skipped.","Handle success/failure in the callback rather than omitting it."],"tags":["csharp","gameframework","argument-validation","null-callback"],"backgroundTag":"null-argument","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}