Ejemplo n.º 1
0
        /// <summary>
        /// Reports an error; adds the exception message and the specified sub message to the error log.
        /// </summary>
        /// <param name="exception"></param>
        /// <param name="subMessage"></param>
        public void ReportError(Exception exception, string subMessage)
        {
            string description = subMessage + exception.Message + Environment.NewLine;

            if (exception.GetType() == typeof(System.IO.PathTooLongException))
            {
                if (NotifyPathTooLongException)
                {
                    if (!ErrorLog.Contains(exception.Message))
                    {
                        ErrorLog += description;
                    }
                }
                return;
            }
            else if (exception.GetType() == typeof(System.IO.DirectoryNotFoundException))
            {
                if (NotifyDirectoryNotFoundException)
                {
                    if (!ErrorLog.Contains(exception.Message))
                    {
                        ErrorLog += description;
                    }
                }
                return;
            }
            else if (exception.GetType() == typeof(UnauthorizedAccessException))
            {
                if (NotifyUnauthorizedAccessException)
                {
                    if (!ErrorLog.Contains(exception.Message))
                    {
                        ErrorLog += description;
                    }
                }
                return;
            }
            else if (exception.GetType() == typeof(System.IO.DirectoryNotFoundException))
            {
                if (NotifyDirectoryNotFoundException)
                {
                    if (!ErrorLog.Contains(exception.Message))
                    {
                        ErrorLog += description;
                    }
                }
                return;
            }
            else if (exception.GetType() == typeof(System.IO.IOException))
            {
                if (NotifyIOException)
                {
                    if (!ErrorLog.Contains(exception.Message))
                    {
                        ErrorLog += description;
                    }
                }
                return;
            }
            else // exception.GetType() == typeof(Exception)
            {
                if (NotifyOtherException)
                {
                    if (!ErrorLog.Contains(exception.Message))
                    {
                        ErrorLog += description;
                    }
                }
                return;
            }
        }