All containers and first level folders are automatically added to Selective Sync...
[pithos-ms-client] / trunk / Pithos.Client.WPF / App.xaml.cs
index c44afb1..b399db6 100644 (file)
@@ -210,18 +210,52 @@ namespace Pithos.Client.WPF
             });
 
 
-            var message = String.Format(@"{0}" + Environment.NewLine + "{1}" + Environment.NewLine + "{2}", 
+            //Do not display any messages if this is a 304 code
+            var ignoreExceptions = from exc in e.Exception.InnerExceptions.OfType<WebException>()
+                                   where IsAllowedException(exc)
+                                   select exc;
+
+            if (ignoreExceptions.Any())
+            {
+                e.SetObserved();
+                return;
+            }
+
+
+           /* var message = String.Format(@"{0}" + Environment.NewLine + "{1}" + Environment.NewLine + "{2}", 
                 WPF.Properties.Resources.Unexpected_Error,
                 WPF.Properties.Resources.We_Apologize, 
                 WPF.Properties.Resources.Please_Submit_Error);
-            ShowMessages("Oops!",message, messages);
+            ShowMessages("Oops!",message, messages);*/
             e.SetObserved();            
         }
 
+        private bool IsAllowedException(Exception exc)
+        {
+            var we = exc as WebException;
+            if (we==null)
+            {
+                return false;
+            }
+            var response = we.Response as HttpWebResponse;
+            return (response != null && response.StatusCode == HttpStatusCode.NotModified);
+        }
+
         private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
         {
+
+            //Do not display any messages if this is a 304 code
+            if (IsAllowedException(e.ExceptionObject as Exception))
+            {
+                return;
+            }
+
             Log.Error("Unhandled exception", (Exception)e.ExceptionObject);
 
+            if (!e.IsTerminating)
+                //Do not display a message unless the application is terminating
+                return;
+
             var description = e.IsTerminating
                               ? WPF.Properties.Resources.Unexpected_Error_Terminating
                               : WPF.Properties.Resources.Unexpected_Error;
@@ -230,7 +264,6 @@ namespace Pithos.Client.WPF
                 WPF.Properties.Resources.We_Apologize,
                 WPF.Properties.Resources.Please_Submit_Error);
 
-
             var exc = ((Exception) e.ExceptionObject);
             var messages = new[]{
                                    new UserMessage
@@ -245,11 +278,19 @@ namespace Pithos.Client.WPF
             ShowMessages("Oops!", message,messages);
         }
 
+
+
         void OnDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
         {
+            //Do not display any messages if this is a 304 code
+            if (IsAllowedException(e.Exception))
+            {
+                return;
+            }
+
             Log.Error("Unhandled Dispatcher exception", e.Exception);
             
-            var messages = new[]{
+           /* var messages = new[]{
                                    new UserMessage
                                        {
                                            Message = e.Exception.Message, 
@@ -259,7 +300,7 @@ namespace Pithos.Client.WPF
                                };
             ShowMessages(WPF.Properties.Resources.Error_Title, 
                 WPF.Properties.Resources.Unexpected_Error,
-                messages);
+                messages);*/
             e.Handled=true;
         }