Skip to content

Commit

Permalink
Bug fix for not rethrowing immediately for non-retriable exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
0x7c13 committed Dec 21, 2023
1 parent 10a3346 commit e214eb5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Notepads/Utilities/FileSystemUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -640,17 +640,23 @@ private static async Task ExecuteFileIOOperationWithRetries(StorageFile file,
}
catch (Exception ex)
{
// Rethrow the last attempt exception regardless of its type
if (retryAttempts == maxRetryAttempts)
{
throw; // Rethrow the last attempt exception
throw;
}
// Delay and retry for retriable errors
else if ((ex.HResult == ERROR_ACCESS_DENIED) ||
(ex.HResult == ERROR_SHARING_VIOLATION) ||
(ex.HResult == ERROR_UNABLE_TO_REMOVE_REPLACED) ||
(ex.HResult == ERROR_FAIL))
{
errorCodes.Add("0x" + Convert.ToString(ex.HResult, 16));
await Task.Delay(10); // Delay 10ms before retrying for all retriable errors
await Task.Delay(10);
}
else // Throw immediately for other errors
{
throw;
}
}
}
Expand Down

0 comments on commit e214eb5

Please sign in to comment.