Skip to content

Commit

Permalink
Catch all ComException
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorixon committed Nov 10, 2024
1 parent 93928ea commit 8053a3d
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using Serilog;

namespace GIMI_ModManager.WinUI.Views.CharacterDetailsPages;

Expand Down Expand Up @@ -237,12 +238,18 @@ private async void ModListArea_OnDragEnter(object sender, DragEventArgs e)
if (ViewModel.CanDragDropMod(storageItems))
e.AcceptedOperation = DataPackageOperation.Copy;
}
catch (COMException exception) when (exception.HResult == -2147221404)
catch (COMException exception)
{
// When drag and dropping a folder from within an archive in WinRAR, GetStorageItemsAsync throws a COMException
// For this case, assume this is a valid drag and drop operation as the command itself will also check if the items are valid
// when (exception.HResult == -2147221404) HResult that is thrown specifically for WinRAR

e.AcceptedOperation = DataPackageOperation.Copy;

if (exception.HResult != -2147221404)
{
Log.Error(exception, "Error while checking if the dragged items are valid.");
}
}
}
}
Expand Down

0 comments on commit 8053a3d

Please sign in to comment.