Added proper handling of the file type exception

This commit is contained in:
MattNL
2023-01-29 22:08:33 -05:00
parent 083128c6bb
commit 8df61a5bb0
2 changed files with 8 additions and 1 deletions

View File

@@ -25,6 +25,7 @@ namespace PckStudio.Classes.IO.PCK
int pck_type = ReadInt(stream);
if (pck_type > 0xf0_00_00) // 03 00 00 00 == true
throw new OverflowException(nameof(pck_type));
else if (pck_type < 3) throw new Exception(pck_type.ToString());
_file = new PCKFile(pck_type);
ReadLookUpTable(stream);
ReadFileEntries(stream);

View File

@@ -171,8 +171,14 @@ namespace PckStudio
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Debug.WriteLine(ex.Message);
}
catch (Exception ex)
{
MessageBox.Show("Failed to open pck\n" +
"If this is an Audio/Music Cues pck, please use the specialized editor while inside of the parent pck.",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Debug.WriteLine("Can't open pck file of type: " + pck?.type.ToString());
}
}
if (pck?.type < 3) throw new Exception("Can't open pck file of type: " + pck.type.ToString());
return pck;
}