Improve error handling

This commit is contained in:
2025-02-04 15:55:32 +03:30
parent 1899e284a0
commit 21365d81bf
2 changed files with 92 additions and 31 deletions
+19 -1
View File
@@ -44,7 +44,25 @@ namespace TBDel.Commands
}
else if (Directory.Exists(filePath))
{
Directory.Delete(filePath);
try
{
Directory.Delete(filePath, true);
}
catch (Exception e)
{
Console.ForegroundColor = ConsoleColor.Red;
if (e.Message.Contains("Directory not empty"))
{
Console.WriteLine("Directory is not empty. It must be empty before it can be deleted or deleted manually.");
}
Console.WriteLine("Something went wrong while deleting the directory.");
Console.ResetColor();
Console.WriteLine(e.Message);
return;
}
if (await dbService.RemoveFolderEntryAsync(id))
{
Console.ForegroundColor = ConsoleColor.Green;