From fcc5a472337f4da9d5f7a7a5319a8285bfce9eb8 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Wed, 18 May 2016 23:10:35 +0200 Subject: [PATCH] My first stack exception trace erasing worst practice ref #299 --- NadekoBot/Classes/Extensions.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/NadekoBot/Classes/Extensions.cs b/NadekoBot/Classes/Extensions.cs index c3062c5f..f82087bd 100644 --- a/NadekoBot/Classes/Extensions.cs +++ b/NadekoBot/Classes/Extensions.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Drawing; using System.IO; using System.Linq; +using System.Net; using System.Security.Cryptography; using System.Threading.Tasks; @@ -166,7 +167,18 @@ namespace NadekoBot.Extensions /// /// /// - public static async Task ShortenUrl(this string str) => await SearchHelper.ShortenUrl(str).ConfigureAwait(false); + public static async Task ShortenUrl(this string str) + { + try + { + var result = await SearchHelper.ShortenUrl(str).ConfigureAwait(false); + return result; + } + catch (WebException) + { + throw new InvalidOperationException("You must enable URL shortner in google developers console."); + } + } /// /// Gets the program runtime