babalae/better-genshin-impact · error · Exception
FolderName 为空
Error message
FolderName 为空
What it means
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.
Source
Thrown at BetterGenshinImpact/Core/Script/Group/ScriptGroupProject.cs:177
public static ScriptGroupProject BuildShellProject(string command)
{
return new ScriptGroupProject(command, "", "Shell");
}
public static ScriptGroupProject BuildPathingProject(string name, string folder)
{
return new ScriptGroupProject(name, folder, "Pathing");
}
/// <summary>
/// 通过 FolderName 查找 ScriptProject
/// </summary>
public void BuildScriptProjectRelation()
{
if (string.IsNullOrEmpty(FolderName))
{
throw new Exception("FolderName 为空");
}
Project = new ScriptProject(FolderName);
}
public string GetHttpAllowedUrlsHash()
{
if (Project == null)
{
BuildScriptProjectRelation();
}
if (Project == null)
{
return "";
}
return string.Join("|", Project.Manifest.HttpAllowedUrls);
}
public async Task Run()View on GitHub (pinned to a7cb36712d)
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.
Example fix
// before
project.BuildScriptProjectRelation();
// after
if (!string.IsNullOrEmpty(project.FolderName))
{
project.BuildScriptProjectRelation();
} Defensive patterns
Strategy: validation
Validate before calling
if (project.Type == "Javascript" && !string.IsNullOrEmpty(project.FolderName))
{
project.BuildScriptProjectRelation();
} Type guard
static bool CanBuildProjectRelation(ScriptGroupProject p) =>
p.Type == "Javascript" && !string.IsNullOrEmpty(p.FolderName); Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- retryInterval 必须大于 0
- 候选文本不能包含空字符串或纯空白字符串
- {paramName} 必须是集合或 JS Array
- {paramName} 中的每个元素都必须是 {typeof(T).Name}
- {paramName} 不能为空
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/0c6ee86fd4794135.
Report an issue: GitHub.