From 875b7b7caaaac9b90827b5e292d52b2f15ea3769 Mon Sep 17 00:00:00 2001 From: Pat Hartl Date: Tue, 28 Nov 2023 20:46:14 -0600 Subject: [PATCH] Throw error messages when exception occurs while browsing an archive --- .../FileManagerComponents/FileManager.razor | 39 ++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/LANCommander/Components/FileManagerComponents/FileManager.razor b/LANCommander/Components/FileManagerComponents/FileManager.razor index b7d91ae..4f23ba3 100644 --- a/LANCommander/Components/FileManagerComponents/FileManager.razor +++ b/LANCommander/Components/FileManagerComponents/FileManager.razor @@ -239,24 +239,37 @@ async Task> GetArchiveDirectoriesAsync(Guid archiveId) { - var entries = await ArchiveService.GetContents(archiveId); - var directories = new HashSet(); - - var root = new FileManagerDirectory + try { - Name = "Root", - Path = "", - IsExpanded = true - }; + var entries = await ArchiveService.GetContents(archiveId); + var directories = new HashSet(); - root.PopulateChildren(entries); + var root = new FileManagerDirectory + { + Name = "Root", + Path = "", + IsExpanded = true + }; - await ChangeDirectory(root, true); + root.PopulateChildren(entries); - return new HashSet + await ChangeDirectory(root, true); + + return new HashSet + { + root + }; + } + catch (FileNotFoundException ex) { - root - }; + MessageService.Error("Could not open archive! Is it missing?"); + } + catch (Exception ex) + { + MessageService.Error("An unknown error occurred trying to open the archive"); + } + + return new HashSet(); } string GetEntryName(IFileManagerEntry entry)