From 8df61a5bb0e927b840e67a71e77e315ef1b3fef1 Mon Sep 17 00:00:00 2001 From: MattNL Date: Sun, 29 Jan 2023 22:08:33 -0500 Subject: [PATCH] Added proper handling of the file type exception --- PCK-Studio/Classes/IO/PCK/PCKFileReader.cs | 1 + PCK-Studio/MainForm.cs | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/PCK-Studio/Classes/IO/PCK/PCKFileReader.cs b/PCK-Studio/Classes/IO/PCK/PCKFileReader.cs index ba10ce98..1e96255c 100644 --- a/PCK-Studio/Classes/IO/PCK/PCKFileReader.cs +++ b/PCK-Studio/Classes/IO/PCK/PCKFileReader.cs @@ -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); diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index 4e326039..e7a989ad 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -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; }