From 869732e8ed31d08955e997e101c8b9476caa8e09 Mon Sep 17 00:00:00 2001 From: TSR Berry <20988865+TSRBerry@users.noreply.github.com> Date: Sun, 28 Jul 2024 22:13:10 +0200 Subject: [PATCH] Catch HorizonResultException in TryLoad --- .../PartitionFileSystemExtensions.cs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Ryujinx.HLE/Loaders/Processes/Extensions/PartitionFileSystemExtensions.cs b/src/Ryujinx.HLE/Loaders/Processes/Extensions/PartitionFileSystemExtensions.cs index b3590d9bd..b3d409e08 100644 --- a/src/Ryujinx.HLE/Loaders/Processes/Extensions/PartitionFileSystemExtensions.cs +++ b/src/Ryujinx.HLE/Loaders/Processes/Extensions/PartitionFileSystemExtensions.cs @@ -71,10 +71,11 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions if (applicationId == 0) { - foreach ((ulong _, ContentMetaData content) in applications) + foreach ((ulong id, ContentMetaData content) in applications) { mainNca = content.GetNcaByType(device.FileSystem.KeySet, ContentType.Program, device.Configuration.UserChannelPersistence.Index); controlNca = content.GetNcaByType(device.FileSystem.KeySet, ContentType.Control, device.Configuration.UserChannelPersistence.Index); + applicationId = id; break; } } @@ -142,7 +143,24 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions } } - return (true, mainNca.Load(device, patchNca, controlNca)); + try + { + return (true, mainNca.Load(device, patchNca, controlNca)); + } + catch (HorizonResultException ex) + { + // The exception message already contains enough information here. + errorMessage = $"Failed to load: {ex.Message}"; + + return (false, ProcessResult.Failed); + } + catch (Exception ex) + { + // Add the stacktrace in addition to the exception message. + errorMessage = $"Failed to load: {ex}"; + + return (false, ProcessResult.Failed); + } } errorMessage = $"Unable to load: Could not find Main NCA for title \"{applicationId:X16}\"";