Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,11 @@ private HttpRequestMessage CreateTokenRequest()
}

private async Task GenerateToken()
{
var request = CreateTokenRequest();

{
for (int i = 0; i < maxRetries + 1; i++){
try
{
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Creating a new HttpRequestMessage on every retry attempt may be inefficient if the request creation involves expensive operations. However, this is necessary since HttpRequestMessage cannot be reused. Consider documenting this behavior with a comment explaining why the request must be created inside the loop.

Suggested change
{
{
// HttpRequestMessage cannot be reused, so we must create a new one on each retry attempt.

Copilot uses AI. Check for mistakes.
var request = CreateTokenRequest();
var response = await httpClient.SendAsync(request).ConfigureAwait(continueOnCapturedContext: false);
response.EnsureSuccessStatusCode();
var tokenResponse = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
Expand All @@ -104,7 +103,8 @@ private async Task GenerateToken()
{
if (i == maxRetries)
{
throw new Exception("Failed to fetch token from server: " + e.Message);
throw new Exception(
$"Failed to fetch token from server: {e.GetType().FullName} - {e.Message}");
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider preserving the original exception's stack trace by using 'throw new Exception(..., e)' to include the inner exception. This would provide better diagnostic information while still customizing the error message.

Suggested change
$"Failed to fetch token from server: {e.GetType().FullName} - {e.Message}");
$"Failed to fetch token from server: {e.GetType().FullName} - {e.Message}", e);

Copilot uses AI. Check for mistakes.
}
await Task.Delay(RetryUtility.CalculateRetryDelay(retriesWaitMs, retriesMaxWaitMs, i))
.ConfigureAwait(false);
Expand Down