From eec96b85498e2f7a33739dd90af2f292389bc67d Mon Sep 17 00:00:00 2001 From: Yeechan Lu Date: Thu, 27 Mar 2014 21:14:41 +0800 Subject: [PATCH] Fix Google Suggestion crash on network error --- Wox.Plugin.System/SuggestionSources/Google.cs | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/Wox.Plugin.System/SuggestionSources/Google.cs b/Wox.Plugin.System/SuggestionSources/Google.cs index 4ae376a8b4..94fc460e3d 100644 --- a/Wox.Plugin.System/SuggestionSources/Google.cs +++ b/Wox.Plugin.System/SuggestionSources/Google.cs @@ -16,26 +16,32 @@ namespace Wox.Plugin.System.SuggestionSources { public override List GetSuggestions(string query) { - var response = - HttpRequest.CreateGetHttpResponse("https://www.google.com/complete/search?output=chrome&q=" + Uri.EscapeUriString(query), null, - null, null); - var stream = response.GetResponseStream(); - - if (stream != null) + try { - var body = new StreamReader(stream).ReadToEnd(); - var json = JsonConvert.DeserializeObject(body) as JContainer; - if (json != null) + var response = + HttpRequest.CreateGetHttpResponse( + "https://www.google.com/complete/search?output=chrome&q=" + Uri.EscapeUriString(query), null, + null, null); + var stream = response.GetResponseStream(); + + if (stream != null) { - var results = json[1] as JContainer; - if (results != null) + var body = new StreamReader(stream).ReadToEnd(); + var json = JsonConvert.DeserializeObject(body) as JContainer; + if (json != null) { - var j = results.OfType().Select(o => o.Value); - return results.OfType().Select(o => o.Value).OfType().ToList(); + var results = json[1] as JContainer; + if (results != null) + { + var j = results.OfType().Select(o => o.Value); + return results.OfType().Select(o => o.Value).OfType().ToList(); + } } } } - + catch + { } + return null; } }