diff --git a/src/HexManiac.Core/Models/StoredMetadata.cs b/src/HexManiac.Core/Models/StoredMetadata.cs index cc8ef172..4040b31b 100644 --- a/src/HexManiac.Core/Models/StoredMetadata.cs +++ b/src/HexManiac.Core/Models/StoredMetadata.cs @@ -163,8 +163,8 @@ namespace HavenSoft.HexManiac.Core.Models { currentItemNote = cleanLine.Split("'''")[1]; } else if (cleanLine.StartsWith("Image = '''")) { currentItemImage = cleanLine.Split("'''")[1]; - } else if (cleanLine.StartsWith("Destination = '''")) { - currentItemDestination = cleanLine.Split("'''")[1]; + } else if (cleanLine.StartsWith("Destination =")) { + currentItemDestination = cleanLine.Split("=")[1].Trim('\'', ' '); } if (cleanLine.StartsWith("ApplicationVersion = '''")) { @@ -378,26 +378,26 @@ namespace HavenSoft.HexManiac.Core.Models { if (currentItem == "[[List]]") { if (currentItemName == null) throw new ArgumentNullException("The Metadata file has a list that didn't specify a name!"); - if (currentItemChildren == null) throw new ArgumentNullException("The Metadata file has a list that didn't specify any children!"); + if (currentItemChildren == null) throw new ArgumentNullException($"List {currentItemName} didn't specify any children!"); lists.Add(new StoredList(currentItemName, currentItemChildren, currentItemHash)); } if (currentItem == "[[UnmappedConstant]]") { if (currentItemName == null) throw new ArgumentNullException("The Metadata file has an unmapped constant that didn't specify a name!"); - if (currentItemValue == -1) throw new ArgumentNullException("The Metadata file has an unmapped constant that didn't specify a value!"); + if (currentItemValue == -1) throw new ArgumentNullException($"Unmapped Constant {currentItemName} didn't specify a value!"); unmappedConstants.Add(new StoredUnmappedConstant(currentItemName, currentItemValue)); } if (currentItem == "[[GotoShortcut]]") { if (currentItemName == null) throw new ArgumentNullException("The Metadata file has a Goto Shortcut that didn't specify a Name!"); - if (currentItemImage == null) throw new ArgumentNullException("The Metadata file has a Goto Shortcut that didn't specify an Image!"); - if (currentItemDestination == null) throw new ArgumentNullException("The Metadata file has a Goto Shortcut that didn't specify a Destination!"); + if (currentItemImage == null) throw new ArgumentNullException($"Goto Shortcut {currentItemName} didn't specify an Image!"); + if (currentItemDestination == null) throw new ArgumentNullException($"Goto Shortcut {currentItemName} didn't specify a Destination!"); gotoShortcuts.Add(new StoredGotoShortcut(currentItemName, currentItemImage, currentItemDestination)); } if (currentItem == "[[TableGroup]]") { if (currentItemName == null) throw new ArgumentNullException("The Metadata file has a TableGroup that didn't specify a name!"); - if (currentItemChildren == null) throw new ArgumentNullException("The Metadat file has a TableGroup that didn't specify any children!"); + if (currentItemChildren == null) throw new ArgumentNullException($"TableGroup {currentItemName} didn't specify any children!"); tableGroups.Add(new(currentItemName, currentItemChildren, currentItemHash)); } diff --git a/src/HexManiac.Core/ViewModels/EditorViewModel.cs b/src/HexManiac.Core/ViewModels/EditorViewModel.cs index fdcd6260..0ec55a8b 100644 --- a/src/HexManiac.Core/ViewModels/EditorViewModel.cs +++ b/src/HexManiac.Core/ViewModels/EditorViewModel.cs @@ -709,7 +709,16 @@ namespace HavenSoft.HexManiac.Core.ViewModels { if (allowLoadingMetadata) { metadataText = fileSystem.MetadataFor(file.Name) ?? new string[0]; } - var metadata = new StoredMetadata(metadataText); + StoredMetadata metadata; + try { + metadata = new StoredMetadata(metadataText); + } catch (ArgumentNullException nullEx) { + ErrorMessage = nullEx.Message; + return; + } catch (ArgumentOutOfRangeException rangeEx) { + ErrorMessage = rangeEx.Message; + return; + } IDataModel model = file.Name.ToLower().EndsWith(".gba") ? new HardcodeTablesModel(Singletons, file.Contents, metadata) : new PokemonModel(file.Contents, metadata, Singletons);