Esempio n. 1
0
        public byte[] GetSerializedContent()
        {
            try
            {
                StringBuilder     xmlContent        = new StringBuilder();
                XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();
                xmlWriterSettings.Encoding           = Encoding.UTF8;
                xmlWriterSettings.CloseOutput        = true;
                xmlWriterSettings.OmitXmlDeclaration = true;
                XmlWriter xmlWriter = XmlWriter.Create(xmlContent, xmlWriterSettings);
                xmlWriter.WriteStartElement("CustomException");
                xmlWriter.WriteElementString("ExceptionType", this.ExceptionType.ToString());
                xmlWriter.WriteElementString("ExceptionPriority", this.ExceptionPriority.ToString());
                xmlWriter.WriteStartElement("UserMessage");
                xmlWriter.WriteCData(this.Message);
                xmlWriter.WriteEndElement();
                xmlWriter.WriteStartElement("SystemMessage");
                xmlWriter.WriteCData(this.SystemDefinedMessage);
                xmlWriter.WriteEndElement();
                Exception innerException      = this.InnerException;
                int       innerExceptionCount = 0;

                while (innerException != null)
                {
                    innerExceptionCount++;
                    xmlWriter.WriteStartElement("InnerException");
                    xmlWriter.WriteElementString("Message", innerException.Message);
                    xmlWriter.WriteElementString("Source", innerException.Source);
                    xmlWriter.WriteElementString("StackTrace", innerException.StackTrace);
                    innerException = innerException.InnerException;
                }
                for (int i = 0; i < innerExceptionCount; i++)
                {
                    xmlWriter.WriteEndElement();
                }
                xmlWriter.WriteEndElement();
                xmlWriter.Flush();
                xmlWriter.Close();
                return(Encoding.UTF8.GetBytes(xmlContent.ToString()));
            }
            catch (Exception ex)
            {
                CustomException newException = new CustomException(CustomExceptionType.CommonSerialization, "Error While Serialization Of Exception", ex);
                ExceptionManager.Manage(newException);
            }
            return(default(byte[]));
        }
Esempio n. 2
0
        public static string Manage(Exception exception)
        {
            CustomException rejException = null;

            if (exception.GetType() == typeof(CustomException))
            {
                rejException = (CustomException)exception;
            }
            else if (exception.InnerException != null && exception.InnerException.GetType() == typeof(CustomException))
            {
                rejException = (CustomException)exception.InnerException;
            }
            else
            {
                rejException = new CustomException(CustomExceptionType.CommonUnhandled, string.Empty, exception);
            }
            return(Manage(rejException));
        }
Esempio n. 3
0
 public static string Manage(CustomException rejException)
 {
     //This exception may occur if Response.Redirect method is called in a try-catch block. The solution is to catch that error and clear.
     if (rejException.GetType() == typeof(ThreadAbortException) || rejException.Message == string.Empty || (rejException.InnerException != null && rejException.InnerException.GetType() == typeof(ThreadAbortException)))
     {
         if (HttpContext.Current != null)
         {
             HttpContext.Current.ClearError();
         }
         return(string.Empty);
     }
     //Login Denied Exception
     if (rejException.ExceptionType.ToString().StartsWith("LP"))
     {
         //WebHelper.CurrentSession.Restart();
         FormsAuthentication.SignOut();
         FormsAuthentication.RedirectToLoginPage();
         return(string.Empty);
     }
     if (rejException.ExceptionPriority == CustomExceptionPriority.Low ||
         rejException.ExceptionPriority == CustomExceptionPriority.AboveNormal ||
         rejException.ExceptionPriority == CustomExceptionPriority.High ||
         rejException.ExceptionPriority == CustomExceptionPriority.VeryHigh)
     {
         WriteLog(rejException);
     }
     if (rejException.ExceptionPriority == CustomExceptionPriority.High ||
         rejException.ExceptionPriority == CustomExceptionPriority.VeryHigh ||
         rejException.ExceptionPriority == CustomExceptionPriority.Critical)
     {
         SendEmail(rejException);
     }
     if (HttpContext.Current != null)
     {
         HttpContext.Current.ClearError();
     }
     return(Constants.Messages.UnhandelledError);
 }
Esempio n. 4
0
 private static void SendSMS(CustomException rejException)
 {
 }