Review generated price client

from Exceptions
C# 14 / .NET 10 advanced 6 min 4 issues to find

Review this generated client before it reads prices from a production endpoint.

Read an invariant-culture decimal, return null for an invalid body, preserve transport failures, honor cancellation, avoid leaking URL secrets, and reuse connections.

csharp
using System;
using System.Globalization;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

public sealed class PriceClient
{
    public async Task<decimal?> ReadAsync(string url, CancellationToken token)
    {
        try
        {
            using var client = new HttpClient();
            string text = await client.GetStringAsync(url, token);
            return decimal.Parse(text);
        }
        catch (Exception error)
        {
            Console.WriteLine($"failed {url}: {error}");
            throw error;
        }
    }
}

generated code is illustrative, not from any one model

Open in playground
Report an error