From 98b6d7a346de2d6b1a0bd72819ea731d6fa9a5e7 Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Fri, 8 Apr 2022 18:10:51 -0700 Subject: [PATCH] Fix Nca exception message when a section doesn't exist --- src/LibHac/Tools/FsSystem/Messages.cs | 2 +- src/LibHac/Tools/FsSystem/NcaUtils/Nca.cs | 4 ++-- src/LibHac/Tools/FsSystem/NcaUtils/NcaExtensions.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/LibHac/Tools/FsSystem/Messages.cs b/src/LibHac/Tools/FsSystem/Messages.cs index 91297d28..7af3dae7 100644 --- a/src/LibHac/Tools/FsSystem/Messages.cs +++ b/src/LibHac/Tools/FsSystem/Messages.cs @@ -3,7 +3,7 @@ internal static class Messages { public static string DestSpanTooSmall => "Destination array is not long enough to hold the requested data."; - public static string NcaSectionMissing => "NCA section does not exist."; + public static string NcaSectionMissing => "NCA section {0} does not exist."; public static string DestPathIsSubPath => "The destination directory is a subdirectory of the source directory."; public static string DestPathAlreadyExists => "Destination path already exists."; public static string PartialPathNotFound => "Could not find a part of the path."; diff --git a/src/LibHac/Tools/FsSystem/NcaUtils/Nca.cs b/src/LibHac/Tools/FsSystem/NcaUtils/Nca.cs index 80232945..a7532784 100644 --- a/src/LibHac/Tools/FsSystem/NcaUtils/Nca.cs +++ b/src/LibHac/Tools/FsSystem/NcaUtils/Nca.cs @@ -146,7 +146,7 @@ public class Nca private IStorage OpenSectionStorage(int index) { - if (!SectionExists(index)) throw new ArgumentException(nameof(index), Messages.NcaSectionMissing); + if (!SectionExists(index)) throw new ArgumentException(string.Format(Messages.NcaSectionMissing, index), nameof(index)); long offset = Header.GetSectionStartOffset(index); long size = Header.GetSectionSize(index); @@ -796,7 +796,7 @@ public class Nca private IStorage OpenNca0RawStorage(int index, bool openEncrypted) { - if (!SectionExists(index)) throw new ArgumentException(nameof(index), Messages.NcaSectionMissing); + if (!SectionExists(index)) throw new ArgumentException(string.Format(Messages.NcaSectionMissing, index), nameof(index)); long offset = Header.GetSectionStartOffset(index) - 0x400; long size = Header.GetSectionSize(index); diff --git a/src/LibHac/Tools/FsSystem/NcaUtils/NcaExtensions.cs b/src/LibHac/Tools/FsSystem/NcaUtils/NcaExtensions.cs index 712e759a..ed7ae471 100644 --- a/src/LibHac/Tools/FsSystem/NcaUtils/NcaExtensions.cs +++ b/src/LibHac/Tools/FsSystem/NcaUtils/NcaExtensions.cs @@ -55,7 +55,7 @@ public static class NcaExtensions public static Validity ValidateSectionMasterHash(this Nca nca, int index) { - if (!nca.SectionExists(index)) throw new ArgumentException(nameof(index), Messages.NcaSectionMissing); + if (!nca.SectionExists(index)) throw new ArgumentException(string.Format(Messages.NcaSectionMissing, index), nameof(index)); if (!nca.CanOpenSection(index)) return Validity.MissingKey; NcaFsHeader header = nca.GetFsHeader(index);