[chronojump] Fixes crash on chronojump if server is down.



commit 4cada90115778a9e49e61bb9189d910c23cccd96
Author: Carles Pina i Estany <carles pina cat>
Date:   Sat Jul 25 19:08:51 2015 +0200

    Fixes crash on chronojump if server is down.

 src/json.cs |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/src/json.cs b/src/json.cs
index 8ae409b..4bb0ad7 100644
--- a/src/json.cs
+++ b/src/json.cs
@@ -72,6 +72,7 @@ public class Json
                try {
                        dataStream = request.GetRequestStream ();
                } catch {
+                       LogB.Warning("Error sending datastream");
                        this.ResultMessage = Catalog.GetString("Could not send file.") + "\n" + 
                                string.Format(Catalog.GetString("You are not connected to the Internet\nor 
{0} server is down."), 
                                                serverUrl);
@@ -83,9 +84,18 @@ public class Json
 
                // Close the Stream object.
                dataStream.Close ();
-
+        
                // Get the response.
-               WebResponse response = request.GetResponse ();
+               WebResponse response;
+               try {
+                       response = request.GetResponse ();
+               } catch {
+                       LogB.Warning("Error getting response");
+                       this.ResultMessage = Catalog.GetString("Could not send file.") + "\n" + 
+                               string.Format(Catalog.GetString("You are not connected to the Internet\nor 
{0} server is down."), 
+                                               serverUrl);
+                       return false;
+               }
 
                // Display the status.
                LogB.Information(((HttpWebResponse)response).StatusDescription);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]