Replace Exception with InvalidOperationException in Metadata.cs

This commit is contained in:
Katy Coe
2019-10-22 16:44:56 +02:00
parent cc2e1b61a6
commit 48df3c42b3

View File

@@ -35,7 +35,7 @@ namespace Il2CppInspector
{ {
// Read magic bytes // Read magic bytes
if (ReadUInt32() != 0xFAB11BAF) { if (ReadUInt32() != 0xFAB11BAF) {
throw new Exception("ERROR: Metadata file supplied is not valid metadata file."); throw new InvalidOperationException("ERROR: Metadata file supplied is not valid metadata file.");
} }
// Set object versioning for Bin2Object from metadata version // Set object versioning for Bin2Object from metadata version
@@ -45,7 +45,7 @@ namespace Il2CppInspector
Header = ReadObject<Il2CppGlobalMetadataHeader>(0); Header = ReadObject<Il2CppGlobalMetadataHeader>(0);
if (Version < 21 || Version > 24) if (Version < 21 || Version > 24)
{ {
throw new Exception($"ERROR: Metadata file supplied is not a supported version ({Header.version})."); throw new InvalidOperationException($"ERROR: Metadata file supplied is not a supported version ({Header.version}).");
} }
// Sanity checking // Sanity checking
@@ -67,7 +67,7 @@ namespace Il2CppInspector
} }
if (realHeaderLength != Sizeof(typeof(Il2CppGlobalMetadataHeader))) { if (realHeaderLength != Sizeof(typeof(Il2CppGlobalMetadataHeader))) {
throw new Exception("ERROR: Could not verify the integrity of the metadata file or accurately identify the metadata sub-version"); throw new InvalidOperationException("ERROR: Could not verify the integrity of the metadata file or accurately identify the metadata sub-version");
} }
// Load all the relevant metadata using offsets provided in the header // Load all the relevant metadata using offsets provided in the header
@@ -85,7 +85,7 @@ namespace Il2CppInspector
} }
if (Images.Any(x => x.token != 1)) if (Images.Any(x => x.token != 1))
throw new Exception("ERROR: Could not verify the integrity of the metadata file image list"); throw new InvalidOperationException("ERROR: Could not verify the integrity of the metadata file image list");
Types = ReadArray<Il2CppTypeDefinition>(Header.typeDefinitionsOffset, Header.typeDefinitionsCount / Sizeof(typeof(Il2CppTypeDefinition))); Types = ReadArray<Il2CppTypeDefinition>(Header.typeDefinitionsOffset, Header.typeDefinitionsCount / Sizeof(typeof(Il2CppTypeDefinition)));
Methods = ReadArray<Il2CppMethodDefinition>(Header.methodsOffset, Header.methodsCount / Sizeof(typeof(Il2CppMethodDefinition))); Methods = ReadArray<Il2CppMethodDefinition>(Header.methodsOffset, Header.methodsCount / Sizeof(typeof(Il2CppMethodDefinition)));