using System; using System.Collections.Generic; using Verse; namespace BlaxDefaults { /// /// Every hook body sits in try/catch and reports here, so a Defaults bug never breaks a construction, a /// designation or a bill. Each hook logs its first failure only. /// /// static void Postfix(...) /// { /// try { ... } /// catch (Exception e) { HookGuard.Report("MakeNewZone", e); } /// } /// /// public static class HookGuard { private static readonly HashSet reported = new HashSet(); public static void Report(string hook, Exception e) { lock (reported) { if (!reported.Add(hook)) return; } Log.Error("[Blax Defaults] " + hook + " failed; later failures of this hook are not logged: " + e); } } }