{"record":{"id":"476c6cb66bc3b3db","repo":"babalae/better-genshin-impact","slug":"main-js-is-empty","errorCode":null,"errorMessage":"main js is empty.","messagePattern":"main js is empty\\.","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/Core/Script/Project/ScriptProject.cs","lineNumber":167,"sourceCode":"            try\n            {\n                engine.Interrupt();\n            }\n            catch (Exception e)\n            {\n                TaskControl.Logger.LogError(e, \"中断脚本执行异常：\" + e.Message);\n            }\n\n            engine.Dispose();\n        }\n    }\n\n    public async Task<string> LoadCode()\n    {\n        var code = await File.ReadAllTextAsync(Path.Combine(ProjectPath, Manifest.Main));\n        if (string.IsNullOrEmpty(code))\n        {\n            throw new FileNotFoundException(\"main js is empty.\");\n        }\n\n        return code;\n    }\n}","sourceCodeStart":149,"sourceCodeEnd":172,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/Core/Script/Project/ScriptProject.cs#L149-L172","documentation":"Thrown by ScriptProject.LoadCode when the main JS file (specified by Manifest.Main) exists but contains empty or null content. Despite the exception type being FileNotFoundException, the file exists — it's just empty. This is a content validation check after reading the file.","triggerScenarios":"Calling LoadCode() on a ScriptProject where Path.Combine(ProjectPath, Manifest.Main) exists but File.ReadAllTextAsync returns an empty string. The main JS entry-point file has zero bytes or only whitespace that gets read as empty.","commonSituations":"The main.js file was created but never filled with code. A file sync or extraction issue resulted in a zero-byte file. The script author created a placeholder file. A Git operation (merge, rebase) left the file empty.","solutions":["Open the main JS file and verify it contains executable JavaScript code.","If the file is empty, add the script logic or restore from a backup/version control.","Check file size: if 0 bytes, re-download or recreate the script.","Use a script template to ensure the main file has valid content."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"var code = await File.ReadAllTextAsync(Path.Combine(projectPath, manifest.Main));\nif (string.IsNullOrWhiteSpace(code))\n    throw new InvalidOperationException($\"Main JS file is empty: {manifest.Main}\");","typeGuard":null,"tryCatchPattern":"try\n{\n    var code = await project.LoadCode();\n}\ncatch (FileNotFoundException ex) when (ex.Message.Contains(\"main js is empty\"))\n{\n    TaskControl.Logger.LogError(\"Main JS file has no content\");\n}","preventionTips":["Check file size after extracting/downloading script packages — zero-byte files indicate corruption.","Ensure the main JS file contains valid JavaScript before deployment.","Use version control to track script file integrity."],"tags":["script-project","empty-file","validation","script-execution"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}