From 6188ff0a2f5469682f4f89f64708525b18fe21ab Mon Sep 17 00:00:00 2001 From: RogueException Date: Sun, 29 Jan 2017 23:11:02 -0400 Subject: [PATCH] Improve platform errors for websocket/udp --- .../DiscordSocketConfig.cs | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/Discord.Net.WebSocket/DiscordSocketConfig.cs b/src/Discord.Net.WebSocket/DiscordSocketConfig.cs index 17640e25b..b47f62dca 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketConfig.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketConfig.cs @@ -34,22 +34,42 @@ namespace Discord.WebSocket public UdpSocketProvider UdpSocketProvider { get; set; } /// Gets or sets whether or not all users should be downloaded as guilds come available. - public bool DownloadUsersOnGuildAvailable { get; set; } = false; + public bool AlwaysDownloadUsers { get; set; } = false; public DiscordSocketConfig() { #if NETSTANDARD1_3 - WebSocketProvider = () => new DefaultWebSocketClient(); - UdpSocketProvider = () => new DefaultUdpSocket(); + WebSocketProvider = () => + { + try + { + return new DefaultWebSocketClient(); + } + catch (PlatformNotSupportedException ex) + { + throw new PlatformNotSupportedException("The default websocket provider is not supported on this platform.", ex); + } + }; + UdpSocketProvider = () => + { + try + { + return new DefaultUdpSocket(); + } + catch (PlatformNotSupportedException ex) + { + throw new PlatformNotSupportedException("The default UDP provider is not supported on this platform.", ex); + } + }; #else WebSocketProvider = () => { - throw new InvalidOperationException("The default websocket provider is not supported on this platform.\n" + + throw new PlatformNotSupportedException("The default websocket provider is not supported on this platform.\n" + "You must specify a WebSocketProvider or target a runtime supporting .NET Standard 1.3, such as .NET Framework 4.6+."); }; UdpSocketProvider = () => { - throw new InvalidOperationException("The default UDP provider is not supported on this platform.\n" + + throw new PlatformNotSupportedException("The default UDP provider is not supported on this platform.\n" + "You must specify a UdpSocketProvider or target a runtime supporting .NET Standard 1.3, such as .NET Framework 4.6+."); }; #endif