Example #1
0
        private void LogException(Exception ex, string caller)
        {
            // Start with a generic error message
            string message = ex.Message;

            // If it is a known exception type, extract some more detailed information.
            CookComputing.XmlRpc.XmlRpcFaultException faultEx = ex as CookComputing.XmlRpc.XmlRpcFaultException;
            if (faultEx != null)
            {
                message = "(" + faultEx.FaultCode + ") " + faultEx.FaultString;
            }

            // Add more exception types if necessary
            string logMessage = SeparatorResourceManager.GetSeparatorString(
                StringId.ExInstrumentCommunicationsFailure) + message + " *** " + caller;

            LogFile.AddMessage(TraceLevel.Warning, logMessage);
            Debug.WriteLine(logMessage);


            // Report the error to the GUI so that it can take appropriate action
            ReportError(2, "TEC1300", new string[] { message });
        }
Example #2
0
 static private void ParseException(Exception ex, ref Exception result)
 {
     if (ex.GetType() == typeof(CookComputing.XmlRpc.XmlRpcFaultException))
     {
         CookComputing.XmlRpc.XmlRpcFaultException xfe = (CookComputing.XmlRpc.XmlRpcFaultException)ex;
         if (xfe.FaultString.IndexOf("repeated requests") > -1)
         {
             result = new ExpectedSyncException(ExpectedError.RepeatedRequests, ex);
         }
         else if (xfe.FaultString.IndexOf("Cannot display this post") > -1)
         {
             result = new ExpectedSyncException(ExpectedError.NoEncodingSettings, ex);
         }
         else if (xfe.FaultString.IndexOf("Invalid password") > -1)
         {
             result = new ExpectedSyncException(ExpectedError.InvalidPassword, ex);
         }
         else if (xfe.FaultString.IndexOf("Unknown method") > -1)
         {
             result = new ExpectedSyncException(ExpectedError.ExportCommentsNotSupported, ex);
         }
     }
     else if (ex.GetType() == typeof(CookComputing.XmlRpc.XmlRpcServerException))
     {
         CookComputing.XmlRpc.XmlRpcServerException xse = (CookComputing.XmlRpc.XmlRpcServerException)ex;
         if (xse.Message.ToLower().IndexOf("not found") > -1 ||
             xse.Message.ToLower().IndexOf("not implemented") > -1 ||
             xse.Message.ToLower().IndexOf("not modified") > -1)
         {
             result = new ExpectedSyncException(ExpectedError.XMLRPCNotSupported, ex);
         }
         else
         {
             result = new ExpectedSyncException(ExpectedError.ServerNotResponding, ex);
         }
     }
     else if (ex.GetType() == typeof(ThreadAbortException))
     {
         result = new ExpectedSyncException(ExpectedError.Cancel, ex);
     }
     else if (ex.GetType() == typeof(System.Net.WebException))
     {
         System.Net.WebException wex = (System.Net.WebException)ex;
         if (wex.Status == System.Net.WebExceptionStatus.ProtocolError)
         {
             result = new ExpectedSyncException(ExpectedError.ExportCommentsNotSupported, ex);
         }
         else
         {
             result = new ExpectedSyncException(ExpectedError.ServerNotResponding, ex);
         }
     }
     else if (ex.GetType() == typeof(CookComputing.XmlRpc.XmlRpcIllFormedXmlException))
     {
         result = new ExpectedSyncException(ExpectedError.ServerNotResponding, ex);
     }
     if (result == null)
     {
         result = ex;
     }
 }