diff --git a/MainForm.cs b/MainForm.cs index 040e459..bfa726a 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -22,18 +22,23 @@ namespace NBTExplorer static MainForm () { - _tagIconIndex = new Dictionary(); - _tagIconIndex[TagType.TAG_BYTE] = 0; - _tagIconIndex[TagType.TAG_SHORT] = 1; - _tagIconIndex[TagType.TAG_INT] = 2; - _tagIconIndex[TagType.TAG_LONG] = 3; - _tagIconIndex[TagType.TAG_FLOAT] = 4; - _tagIconIndex[TagType.TAG_DOUBLE] = 5; - _tagIconIndex[TagType.TAG_BYTE_ARRAY] = 6; - _tagIconIndex[TagType.TAG_STRING] = 7; - _tagIconIndex[TagType.TAG_LIST] = 8; - _tagIconIndex[TagType.TAG_COMPOUND] = 9; - _tagIconIndex[TagType.TAG_INT_ARRAY] = 14; + try { + _tagIconIndex = new Dictionary(); + _tagIconIndex[TagType.TAG_BYTE] = 0; + _tagIconIndex[TagType.TAG_SHORT] = 1; + _tagIconIndex[TagType.TAG_INT] = 2; + _tagIconIndex[TagType.TAG_LONG] = 3; + _tagIconIndex[TagType.TAG_FLOAT] = 4; + _tagIconIndex[TagType.TAG_DOUBLE] = 5; + _tagIconIndex[TagType.TAG_BYTE_ARRAY] = 6; + _tagIconIndex[TagType.TAG_STRING] = 7; + _tagIconIndex[TagType.TAG_LIST] = 8; + _tagIconIndex[TagType.TAG_COMPOUND] = 9; + _tagIconIndex[TagType.TAG_INT_ARRAY] = 14; + } + catch (Exception e) { + Program.StaticInitFailure(e); + } } public MainForm () diff --git a/Model/FileTypeRegistry.cs b/Model/FileTypeRegistry.cs index 2d745f0..64e746b 100644 --- a/Model/FileTypeRegistry.cs +++ b/Model/FileTypeRegistry.cs @@ -45,20 +45,25 @@ namespace NBTExplorer.Model static FileTypeRegistry () { - Register(new FileTypeRecord() { - NamePatternTest = NbtFileDataNode.SupportedNamePattern, - NodeCreate = NbtFileDataNode.TryCreateFrom, - }); + try { + Register(new FileTypeRecord() { + NamePatternTest = NbtFileDataNode.SupportedNamePattern, + NodeCreate = NbtFileDataNode.TryCreateFrom, + }); - Register(new FileTypeRecord() { - NamePatternTest = RegionFileDataNode.SupportedNamePattern, - NodeCreate = RegionFileDataNode.TryCreateFrom, - }); + Register(new FileTypeRecord() { + NamePatternTest = RegionFileDataNode.SupportedNamePattern, + NodeCreate = RegionFileDataNode.TryCreateFrom, + }); - Register(new FileTypeRecord() { - NamePatternTest = CubicRegionDataNode.SupportedNamePattern, - NodeCreate = CubicRegionDataNode.TryCreateFrom, - }); + Register(new FileTypeRecord() { + NamePatternTest = CubicRegionDataNode.SupportedNamePattern, + NodeCreate = CubicRegionDataNode.TryCreateFrom, + }); + } + catch (Exception e) { + Program.StaticInitFailure(e); + } } } } diff --git a/Program.cs b/Program.cs index 41b41d1..b04b0b8 100644 --- a/Program.cs +++ b/Program.cs @@ -16,5 +16,17 @@ namespace NBTExplorer Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); } + + public static void StaticInitFailure (Exception e) + { + Console.WriteLine("Static Initialization Failure:"); + while (e != null) { + Console.WriteLine(e.Message); + Console.WriteLine(e.StackTrace); + e = e.InnerException; + } + + Application.Exit(); + } } }