Skip to content

Commit 2d58170

Browse files
committed
Swallow exceptions when gathering runtime information
1 parent 3d674b7 commit 2d58170

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/Stripe.net/Infrastructure/Public/SystemNetHttpClient.cs

+14-2
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,23 @@ private string BuildStripeClientUserAgentString()
222222
{ "bindings_version", StripeConfiguration.StripeNetVersion },
223223
{ "lang", ".net" },
224224
{ "publisher", "stripe" },
225-
{ "lang_version", RuntimeInformation.GetRuntimeVersion() },
226-
{ "os_version", RuntimeInformation.GetOSVersion() },
227225
{ "stripe_net_target_framework", StripeNetTargetFramework },
228226
};
229227

228+
// The following values are in a try/catch block on the off chance that the
229+
// RuntimeInformation methods fail in an unexpected way. This should ~never happen, but
230+
// if it does it should not prevent users from sending requests.
231+
// See https://github.com/stripe/stripe-dotnet/issues/1986 for context.
232+
try
233+
{
234+
values.Add("lang_version", RuntimeInformation.GetRuntimeVersion());
235+
values.Add("os_version", RuntimeInformation.GetOSVersion());
236+
}
237+
catch (Exception)
238+
{
239+
// Do nothing.
240+
}
241+
230242
if (this.appInfo != null)
231243
{
232244
values.Add("application", this.appInfo);

0 commit comments

Comments
 (0)