Fix Nca exception message when a section doesn't exist

This commit is contained in:
Alex Barney 2022-04-08 18:10:51 -07:00
parent 96b3fd670b
commit 98b6d7a346
3 changed files with 4 additions and 4 deletions

View file

@ -3,7 +3,7 @@
internal static class Messages internal static class Messages
{ {
public static string DestSpanTooSmall => "Destination array is not long enough to hold the requested data."; 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 DestPathIsSubPath => "The destination directory is a subdirectory of the source directory.";
public static string DestPathAlreadyExists => "Destination path already exists."; public static string DestPathAlreadyExists => "Destination path already exists.";
public static string PartialPathNotFound => "Could not find a part of the path."; public static string PartialPathNotFound => "Could not find a part of the path.";

View file

@ -146,7 +146,7 @@ public class Nca
private IStorage OpenSectionStorage(int index) 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 offset = Header.GetSectionStartOffset(index);
long size = Header.GetSectionSize(index); long size = Header.GetSectionSize(index);
@ -796,7 +796,7 @@ public class Nca
private IStorage OpenNca0RawStorage(int index, bool openEncrypted) 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 offset = Header.GetSectionStartOffset(index) - 0x400;
long size = Header.GetSectionSize(index); long size = Header.GetSectionSize(index);

View file

@ -55,7 +55,7 @@ public static class NcaExtensions
public static Validity ValidateSectionMasterHash(this Nca nca, int index) 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; if (!nca.CanOpenSection(index)) return Validity.MissingKey;
NcaFsHeader header = nca.GetFsHeader(index); NcaFsHeader header = nca.GetFsHeader(index);