huiyadanli/RevokeMsgPatcher · error · Exception
补丁安装失败,原因:文件修改器初始化失败!
Error message
补丁安装失败,原因:文件修改器初始化失败!
What it means
AppModifier.Patch() throws a plain Exception if any element of the editors list is null. In the normal flow InitEditors only adds non-null FileHexEditor instances, so a null implies the list was externally mutated or a subclass/test injected a null.
Source
Thrown at RevokeMsgPatcher/Modifier/AppModifier.cs:399
/// <summary>
/// c.根据补丁信息,安装补丁
/// 两种打补丁的方式:精准(指定位置替换)、通用(特征码替换)
/// </summary>
/// <returns></returns>
public bool Patch()
{
// 首先验证文件修改器是否没问题
if (editors.Count == 0)
{
throw new Exception("补丁安装失败,原因:无对应的文件修改器");
}
foreach (FileHexEditor editor in editors)
{
if (editor == null)
{
throw new Exception("补丁安装失败,原因:文件修改器初始化失败!");
}
}
// 再备份所有文件
foreach (FileHexEditor editor in editors)
{
editor.Backup();
}
// 打补丁!
List<FileHexEditor> done = new List<FileHexEditor>(); // 已经打上补丁的
try
{
foreach (FileHexEditor editor in editors)
{
bool success = editor.Patch();
if (!success)
{View on GitHub (pinned to 89cbbb3f0c)
Solutions
- Do not mutate the editors list after InitEditors.
- If subclassing AppModifier, ensure every editor added is non-null.
- Filter nulls out of editors before calling Patch().
Defensive patterns
Strategy: validation
Validate before calling
if (editors == null || editors.Any(e => e == null))
{
throw new InvalidOperationException("editors 列表包含 null,请检查初始化逻辑。");
}
if (editors.Count == 0)
{
throw new Exception("补丁安装失败,原因:无对应的文件修改器");
} Prevention
- Do not mutate the editors list after InitEditors; let it be the single source.
- In subclasses, only add non-null FileHexEditor instances.
- Fail loudly on a null editor during init rather than at Patch time.
When it happens
Trigger: The editors list contains a null entry when Patch() runs. Not reachable through the public API if InitEditors is the only thing populating editors.
Common situations: Subclass or integration code replaced editors with a list containing null; a failed FileHexEditor constructor result was added manually.
Related errors
AI-assisted analysis of huiyadanli/RevokeMsgPatcher@89cbbb3f0c (2026-08-13).
Data as JSON: /api/errors/3e510e25d180bd1a.
Report an issue: GitHub.