Skip to content

Commit a07d924

Browse files
authored
Merge pull request #322 from graphql-dotnet/swallow-pns-exceptions
catch PlatformNotSupportedException for unsupported Options properties
2 parents 5356743 + 14f30c9 commit a07d924

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/GraphQL.Client/Websocket/GraphQLHttpWebSocket.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,26 @@ public Task InitializeWebSocket()
402402
#else
403403
_clientWebSocket = new ClientWebSocket();
404404
_clientWebSocket.Options.AddSubProtocol("graphql-ws");
405-
if(!System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Create("BROWSER")))
405+
406+
// the following properties are not supported in Blazor WebAssembly and throw a PlatformNotSupportedException error when accessed
407+
try
406408
{
407-
// the following properties are not supported in Blazor WebAssembly and throw a PlatformNotSupportedException error when accessed
408409
_clientWebSocket.Options.ClientCertificates = ((HttpClientHandler)Options.HttpMessageHandler).ClientCertificates;
410+
}
411+
catch (PlatformNotSupportedException)
412+
{
413+
Debug.WriteLine("property 'ClientWebSocketOptions.ClientCertificates' not supported by current platform");
414+
}
415+
416+
try
417+
{
409418
_clientWebSocket.Options.UseDefaultCredentials = ((HttpClientHandler)Options.HttpMessageHandler).UseDefaultCredentials;
410419
}
420+
catch (PlatformNotSupportedException)
421+
{
422+
Debug.WriteLine("Property 'ClientWebSocketOptions.UseDefaultCredentials' not supported by current platform");
423+
}
424+
411425
Options.ConfigureWebsocketOptions(_clientWebSocket.Options);
412426
#endif
413427
return _initializeWebSocketTask = ConnectAsync(_internalCancellationToken);

0 commit comments

Comments
 (0)