Skip to content

Commit a20f9ad

Browse files
Copilotalerickson
andcommitted
Add error handling for temp file cleanup in validation failure path
Co-authored-by: alerickson <25858831+alerickson@users.noreply.github.com>
1 parent 35882de commit a20f9ad

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/code/RepositorySettings.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -884,9 +884,10 @@ public static PSRepositoryInfo Reset(PSCmdlet cmdletPassedIn, out string errorMs
884884
{
885885
File.Delete(tempFilePath);
886886
}
887-
catch
887+
catch (Exception cleanupEx)
888888
{
889-
// Ignore cleanup errors for temp file
889+
errorMsg = string.Format(CultureInfo.InvariantCulture, "Failed to validate newly created repository store file with error: {0}. Additionally, cleanup of temporary file failed with error: {1}", loadEx.Message, cleanupEx.Message);
890+
return null;
890891
}
891892
}
892893
errorMsg = string.Format(CultureInfo.InvariantCulture, "Failed to validate newly created repository store file with error: {0}.", loadEx.Message);

0 commit comments

Comments
 (0)