});
- 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;
WPF.Properties.Resources.We_Apologize,
WPF.Properties.Resources.Please_Submit_Error);
-
var exc = ((Exception) e.ExceptionObject);
var messages = new[]{
new UserMessage
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,
};
ShowMessages(WPF.Properties.Resources.Error_Title,
WPF.Properties.Resources.Unexpected_Error,
- messages);
+ messages);*/
e.Handled=true;
}