{"record":{"id":"a5ec9aa971968395","repo":"EllanJiang/GameFramework","slug":"config-name-0-is-not-exist","errorCode":null,"errorMessage":"Config name '{0}' is not exist.","messagePattern":"Config name '(.+?)' is not exist\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Config/ConfigManager.cs","lineNumber":307,"sourceCode":"        /// </summary>\n        /// <param name=\"configName\">要检查全局配置项的名称。</param>\n        /// <returns>指定的全局配置项是否存在。</returns>\n        public bool HasConfig(string configName)\n        {\n            return GetConfigData(configName).HasValue;\n        }\n\n        /// <summary>\n        /// 从指定全局配置项中读取布尔值。\n        /// </summary>\n        /// <param name=\"configName\">要获取全局配置项的名称。</param>\n        /// <returns>读取的布尔值。</returns>\n        public bool GetBool(string configName)\n        {\n            ConfigData? configData = GetConfigData(configName);\n            if (!configData.HasValue)\n            {\n                throw new GameFrameworkException(Utility.Text.Format(\"Config name '{0}' is not exist.\", configName));\n            }\n\n            return configData.Value.BoolValue;\n        }\n\n        /// <summary>\n        /// 从指定全局配置项中读取布尔值。\n        /// </summary>\n        /// <param name=\"configName\">要获取全局配置项的名称。</param>\n        /// <param name=\"defaultValue\">当指定的全局配置项不存在时，返回此默认值。</param>\n        /// <returns>读取的布尔值。</returns>\n        public bool GetBool(string configName, bool defaultValue)\n        {\n            ConfigData? configData = GetConfigData(configName);\n            return configData.HasValue ? configData.Value.BoolValue : defaultValue;\n        }\n\n        /// <summary>","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Config/ConfigManager.cs#L289-L325","documentation":"ConfigManager.GetBool looks up a config by exact name; if no config data with that name exists (GetConfigData returns null), it throws GameFrameworkException with the offending name. It signals a lookup of a config string that was never loaded or registered.","triggerScenarios":"Calling GetBool(\"SomeName\") where SomeName was never added via AddConfig/LoadConfig, or the config asset/table failed to load, or the name has a typo/different casing.","commonSituations":"Renaming a config key in the table but not in code; config file not loaded before first access (initialization order); locale/variant config tables missing an entry.","solutions":["Verify the config name exists in the loaded config table (check spelling and case)","Ensure the config file/table is loaded (LoadConfig / LoadDictionary) before calling GetBool","If optional, use configData.HasValue via GetConfigData pattern or your own Contains check before reading"],"exampleFix":"// before\nbool soundOn = m_ConfigManager.GetBool(\"Sound.Enable\"); // may not exist\n// after\nif (m_ConfigManager.HasConfig(\"Sound.Enable\"))\n{\n    bool soundOn = m_ConfigManager.GetBool(\"Sound.Enable\");\n}\nelse\n{\n    bool soundOn = true; // default\n}","handlingStrategy":"fallback","validationCode":"if (!configManager.HasConfig(name)) { /* use default */ }\nbool value = configManager.GetBool(name);","typeGuard":null,"tryCatchPattern":"try { return configManager.GetBool(name); }\ncatch (GameFrameworkException) { return defaultValue; }","preventionTips":["Keep config key names in constants shared with the table","Load config tables during startup before first access","Provide defaults for optional keys","Verify spelling/case when renaming keys"],"tags":["config","missing-key","lookup","gameframework"],"backgroundTag":"resource-not-found","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"}