public LogException(Exception ex)
            : this()
        {
            Message       = ex.Message;
            Source        = ex.Source;
            StackTrace    = ex.StackTrace;
            HelpLink      = ex.HelpLink;
            ExceptionType = ex.GetType().FullName;
            if (ex.InnerException != null)
            {
                InnerException = new LogException(ex.InnerException);
            }

            foreach (object key in ex.Data.Keys)
            {
                string keyString = key.ToString();
                Data.Add(new Property(keyString, ex.Data[key]));
            }

            //-------------------------------------------------------
            // use reflection to get all public properties on the
            //	exception being examined except those defined in
            //	_filterList (generally just those in base Exception class)
            //-------------------------------------------------------
            this.Properties = Reflector.GetPublicProperties(ex, _filterList);

            TargetSite = (ex.TargetSite == null)?"(null)":ex.TargetSite.ToString();
            ErrorCode  = Reflector.GetProtectedProperty <int>("HResult", ex, default(int)).ToString();
        }
		public LogException(Exception ex)
			: this()
		{
			Message = ex.Message;
			Source = ex.Source;
			StackTrace = ex.StackTrace;
			HelpLink = ex.HelpLink;
			ExceptionType = ex.GetType().FullName;
			if (ex.InnerException != null)
			{
				InnerException = new LogException(ex.InnerException );
			}

			foreach (object key in ex.Data.Keys)
			{
				string keyString = key.ToString();
				Data.Add(new Property(keyString, ex.Data[key]));
			}

			//-------------------------------------------------------
			// use reflection to get all public properties on the
			//	exception being examined except those defined in 
			//	_filterList (generally just those in base Exception class)
			//-------------------------------------------------------			
			this.Properties = Reflector.GetPublicProperties(ex, _filterList);
			
			TargetSite = (ex.TargetSite == null)?"(null)":ex.TargetSite.ToString();
			ErrorCode = Reflector.GetProtectedProperty<int>("HResult", ex, default(int)).ToString();
		}
        public object Clone()
        {
            var retEx = new LogException()
            {
                ErrorCode     = this.ErrorCode,
                ExceptionType = this.ExceptionType,
                HelpLink      = this.HelpLink,
                Message       = this.Message,
                Source        = this.Source,
                StackTrace    = this.StackTrace,
                TargetSite    = this.TargetSite
            };

            if (InnerException != null)
            {
                retEx.InnerException = (LogException)InnerException.Clone();
            }
            if (Data != null && Data.Count > 0)
            {
                foreach (var item in Data)
                {
                    retEx.Data.Add(item.Clone() as Property);
                }
            }

            if (Properties != null && Properties.Count > 0)
            {
                foreach (var prop in Properties)
                {
                    retEx.Properties.Add(prop.Clone() as Property);
                }
            }
            return(retEx);
        }
Exemple #4
0
 /// <summary>
 /// Creates an ERROR level message
 /// </summary>
 /// <param name="referenceKey">Field/Property level name (used for IDataErrorInfo bindings)</param>
 /// <param name="ex">Exception to associate with this message.  Should be serializable if state is going to be sent across application boundries</param>
 /// <param name="messageText">Text to associate with this state</param>
 /// <param name="args">Arguments to supply ot this text</param>
 public ActionReplyMessageItem(string referenceKey, Exception ex, string messageText, params object[] args)
 {
     Exception    = new LogException(ex);
     MessageText  = TextUtils.StringFormat(messageText, args);
     Severity     = ActionStatus.InternalError;
     ReferenceKey = referenceKey;
 }
Exemple #5
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="item"></param>
 public ActionReplyMessageItem(ActionReplyMessageItem item)
 {
     Exception    = item.Exception;
     Severity     = item.Severity;
     MessageText  = item.MessageText;
     ReferenceKey = item.ReferenceKey;
 }
Exemple #6
0
 /// <summary>
 /// Creates an ERROR level message.  MessageText = ex.Message
 /// </summary>
 /// <param name="referenceKey">Field/Property level name (used for IDataErrorInfo bindings)</param>
 /// <param name="ex">Exception to associate with this message.  Should be serializable if state is going to be sent across application boundries</param>
 public ActionReplyMessageItem(string referenceKey, Exception ex)
 {
     Exception = new LogException(ex);
     if (ex != null)
     {
         MessageText = ex.Message;
     }
     Severity     = ActionStatus.InternalError;
     ReferenceKey = referenceKey;
 }
Exemple #7
0
        public ActionReplyMessageItem(Exception ex, ActionStatus severity)
        {
            Exception = new LogException(ex);
            if (ex != null)
            {
                MessageText = ex.Message;
            }

            Severity = severity;
        }
Exemple #8
0
        public static string Expand(LogException ex, int offSetIndex)
        {
            StringBuilder sb            = new StringBuilder();
            string        paddingString = "";

            if (offSetIndex > 0)
            {
                paddingString = new String(' ', offSetIndex);
            }


            sb.AppendLine("{1}===== Begin {0} =====", ex.ExceptionType, paddingString);
            _expandException(ex, 0, sb);
            sb.AppendLine("{1}===== End {0} =====", ex.ExceptionType, paddingString);

            return(sb.ToString().Replace(Environment.NewLine, Environment.NewLine + paddingString));
        }
Exemple #9
0
        private static void _expandException(LogException ex, int offSet, StringBuilder sb)
        {
            string paddingString = "";

            if (offSet > 1)
            {
                paddingString = new String(' ', offSet);
            }

            string replacementString = Environment.NewLine + paddingString + new String(' ', 24);

            makeLine(sb, "Message", ex.Message, replacementString, paddingString);
            makeLine(sb, "Error Code", ex.ErrorCode, replacementString, paddingString);
            makeLine(sb, "Exception Type", ex.ExceptionType, replacementString, paddingString);
            foreach (var prop in ex.Properties)
            {
                makeLine(sb, prop.Key, string.Format("{0} [{1}]", prop.Value, prop.ValueType), replacementString, paddingString);
            }
            makeLine(sb, "Source", ex.Source, replacementString, paddingString);
            makeLine(sb, "Stack Trace", ex.StackTrace, replacementString, paddingString);
            makeLine(sb, "Target Site", ex.TargetSite, replacementString, paddingString);
            makeLine(sb, "HelpLink", ex.HelpLink, replacementString, paddingString);
            if (ex.InnerException != null)
            {
                sb.AppendFormat("{0}    ----- Inner {1} (begin) -----{2}", paddingString, ex.InnerException.ExceptionType, Environment.NewLine);
                _expandException(ex.InnerException, offSet + 4, sb);
                sb.AppendFormat("{0}    ----- Inner {1} (end) ------{2}", paddingString, ex.InnerException.ExceptionType, Environment.NewLine);
            }
            if (ex.Data != null && ex.Data.Count > 0)
            {
                foreach (var dataItem in ex.Data)
                {
                    var key = string.Format("Data[{0}]", dataItem.Key);
                    makeLine(sb, key, dataItem.Value, replacementString, paddingString);
                }
            }
        }
        public ActionReplyMessageItem(Exception ex, ActionStatus severity)
        {
            Exception = new LogException(ex);
			if (ex != null)
			{
				MessageText = ex.Message;
			}
            
            Severity = severity;
        }
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="item"></param>
 public ActionReplyMessageItem(ActionReplyMessageItem item)
 {
     Exception = item.Exception;
     Severity = item.Severity;
     MessageText = item.MessageText;
     ReferenceKey = item.ReferenceKey;
 }
 /// <summary>
 /// Creates an ERROR level message
 /// </summary>
 /// <param name="referenceKey">Field/Property level name (used for IDataErrorInfo bindings)</param>
 /// <param name="ex">Exception to associate with this message.  Should be serializable if state is going to be sent across application boundries</param>
 /// <param name="messageText">Text to associate with this state</param>
 /// <param name="args">Arguments to supply ot this text</param>
 public ActionReplyMessageItem(string referenceKey, Exception ex, string messageText, params object[] args)
 {
     Exception = new LogException(ex);
     MessageText = TextUtils.StringFormat(messageText, args);
     Severity = ActionStatus.InternalError;
     ReferenceKey = referenceKey;
 }
        /// <summary>
        /// Creates an ERROR level message.  MessageText = ex.Message
        /// </summary>
        /// <param name="referenceKey">Field/Property level name (used for IDataErrorInfo bindings)</param>
        /// <param name="ex">Exception to associate with this message.  Should be serializable if state is going to be sent across application boundries</param>
        public ActionReplyMessageItem(string referenceKey, Exception ex)
        {
            Exception = new LogException(ex);
			if (ex != null)
			{
				MessageText = ex.Message;
			}
            Severity = ActionStatus.InternalError;
            ReferenceKey = referenceKey;
        }
Exemple #14
0
 /// <summary>
 /// (ScrimpNet.Core extension) Creates a string of all exception properties
 /// </summary>
 /// <param name="ex">Exception to expand</param>
 /// <returns>Well defined string of all exception properties; includes all inner exceptions</returns>
 public static string Expand(this LogException ex)
 {
     return(Utils.Expand(ex));
 }
Exemple #15
0
 public static string Expand(LogException ex)
 {
     return(Expand(ex, 0));
 }
Exemple #16
0
 /// <summary>
 /// (ScrimpNet.Core extension) Creates a string of all exception properties
 /// </summary>
 /// <param name="ex">Exception to expand</param>
 /// <param name="offSet">Number of leading spacing characters to prepend to exception lines</param>
 /// <returns>Well defined string of all exception properties; includes all inner exceptions</returns>
 public static string Expand(this LogException ex, int offSet)
 {
     return(Utils.Expand(ex, offSet));
 }
		public object Clone()
		{
			var retEx = new LogException()
			{
				ErrorCode = this.ErrorCode,
				ExceptionType = this.ExceptionType,
				HelpLink = this.HelpLink,
				Message = this.Message,
				Source = this.Source,
				StackTrace = this.StackTrace,
				TargetSite = this.TargetSite
			};
			if (InnerException != null)
			{
				retEx.InnerException = (LogException)InnerException.Clone();
			}
			if (Data != null && Data.Count > 0)
			{
				foreach (var item in Data)
				{
					retEx.Data.Add(item.Clone() as Property);
				}
			}

			if (Properties != null && Properties.Count > 0)
			{
				foreach (var prop in Properties)
				{
					retEx.Properties.Add(prop.Clone() as Property);
				}
			}
			return retEx;
		}