{"record":{"id":"0c6ee86fd4794135","repo":"babalae/better-genshin-impact","slug":"foldername","errorCode":null,"errorMessage":"FolderName 为空","messagePattern":"FolderName 为空","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/Core/Script/Group/ScriptGroupProject.cs","lineNumber":177,"sourceCode":"\n    public static ScriptGroupProject BuildShellProject(string command)\n    {\n        return new ScriptGroupProject(command, \"\", \"Shell\");\n    }\n\n    public static ScriptGroupProject BuildPathingProject(string name, string folder)\n    {\n        return new ScriptGroupProject(name, folder, \"Pathing\");\n    }\n\n    /// <summary>\n    /// 通过 FolderName 查找 ScriptProject\n    /// </summary>\n    public void BuildScriptProjectRelation()\n    {\n        if (string.IsNullOrEmpty(FolderName))\n        {\n            throw new Exception(\"FolderName 为空\");\n        }\n        Project = new ScriptProject(FolderName);\n    }\n\n    public string GetHttpAllowedUrlsHash()\n    {\n        if (Project == null)\n        {\n            BuildScriptProjectRelation();\n        }\n        if (Project == null)\n        {\n            return \"\";\n        }\n        return string.Join(\"|\", Project.Manifest.HttpAllowedUrls);\n    }\n\n    public async Task Run()","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/Core/Script/Group/ScriptGroupProject.cs#L159-L195","documentation":"Thrown by ScriptGroupProject.BuildScriptProjectRelation when FolderName is null or empty. This method lazily constructs the ScriptProject from FolderName — it's a guard ensuring the folder reference exists before attempting to build the project relation. Called from GetHttpAllowedUrlsHash and other places that need the Project.","triggerScenarios":"Calling BuildScriptProjectRelation() or GetHttpAllowedUrlsHash() on a ScriptGroupProject that was created without a folder name (e.g. via BuildShellProject which passes empty string as folder). Any ScriptGroupProject instance whose FolderName was never set or was set to empty.","commonSituations":"A Shell-type project or KeyMouse-type project (which don't have script folders) triggers a code path that calls BuildScriptProjectRelation. Incorrectly configured ScriptGroupProject JSON where FolderName is missing. Accidental access to Project-related members on non-JS project types.","solutions":["Check Type and FolderName before calling BuildScriptProjectRelation — only 'Javascript' projects have folders.","Ensure the ScriptGroupProject was properly constructed with a valid FolderName for JS projects.","Guard callers: if (project.Type == \"Javascript\" && !string.IsNullOrEmpty(project.FolderName)) before accessing Project."],"exampleFix":"// before\nproject.BuildScriptProjectRelation();\n// after\nif (!string.IsNullOrEmpty(project.FolderName))\n{\n    project.BuildScriptProjectRelation();\n}","handlingStrategy":"validation","validationCode":"if (project.Type == \"Javascript\" && !string.IsNullOrEmpty(project.FolderName))\n{\n    project.BuildScriptProjectRelation();\n}","typeGuard":"static bool CanBuildProjectRelation(ScriptGroupProject p) =>\n    p.Type == \"Javascript\" && !string.IsNullOrEmpty(p.FolderName);","tryCatchPattern":null,"preventionTips":["Only call BuildScriptProjectRelation on Javascript-type projects with a valid FolderName.","Avoid calling Project-dependent members on Shell or KeyMouse type projects.","Check Type before accessing Project-related functionality."],"tags":["argument-validation","script-group","project-initialization"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}