示例#1
0
        /// <summary>
        /// Log the custom/user exception to the specified log sink
        /// </summary>
        /// <param name="objectException"></param>
        public static void HandleException(OMEException objectException)
        {
            string str = string.Empty;
            string message = string.Empty;
            str = ExceptionHandler.HandleException(objectException, 1);

            message = objectException.Message.ToString();
            if (String.IsNullOrEmpty(objectException.ErrorCode))
                message = objectException.ExMessage;
            OMETrace.WriteLine(string.Empty);
            OMETrace.WriteLine(message);
            OMETrace.WriteLine(objectException.StackTrace);
        }
示例#2
0
        /// <summary>
        /// Show error messege
        /// </summary>
        /// <param name="objException"></param>
        public static void ShowOMEMessage(OMEException objException)
        {
            string str = string.Empty;
            string message = string.Empty;
            str = ExceptionHandler.HandleException(objException, 1);

            message = objException.Message.ToString();
            if (String.IsNullOrEmpty(objException.ErrorCode))
                message = objException.ExMessage;
            OMETrace.WriteLine(string.Empty);
            OMETrace.WriteLine(message);
            OMETrace.WriteLine(objException.StackTrace);
            MessageBox.Show(str, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
示例#3
0
        public static string HandleDBException(OMEException objEx, int stackLevel)
        {
            string messageFromResourceFile = objEx.ErrorCode;
            if (String.IsNullOrEmpty(messageFromResourceFile))
                messageFromResourceFile = objEx.ExMessage;

            if (!m_ExceptionLoggingInfo.IsLoggingEnabled)
            {
                return messageFromResourceFile;
            }

            if (m_ExceptionLoggingInfo.CriticalityLevel.ToUpper() == "HIGH")
            {
                if (objEx.criticalityLevel == CriticalityLevel.HIGH)
                {
                    LogDBException(objEx, stackLevel);
                }
            }
            else if (m_ExceptionLoggingInfo.CriticalityLevel.ToUpper() == "MEDIUM")
            {
                if (objEx.criticalityLevel == CriticalityLevel.HIGH || objEx.criticalityLevel == CriticalityLevel.MEDIUM)
                {
                    LogDBException(objEx, stackLevel);
                }
            }
            else if (m_ExceptionLoggingInfo.CriticalityLevel.ToUpper() == "LOW")
            {
                if (objEx.criticalityLevel == CriticalityLevel.HIGH || objEx.criticalityLevel == CriticalityLevel.MEDIUM || objEx.criticalityLevel == CriticalityLevel.MEDIUM || objEx.criticalityLevel == CriticalityLevel.LOW)
                {
                    LogDBException(objEx, stackLevel);
                }
            }
            return messageFromResourceFile;
        }
示例#4
0
        private static void LogException(OMEException oEx)
        {
            string traceInfo = null;

            if (oEx.traceInfo == StackTraceType.ENHANCED)
            {
                //StackTrace st = new StackTrace(true);
                //traceInfo = OMEStackTrace.EnhancedStackTrace(st);
                traceInfo = OMEStackTrace.EnhancedStackTrace(oEx.StackTrace);
            }
            else if (oEx.traceInfo == StackTraceType.BRIEF)
            {
                StackTrace st = new StackTrace(true);
                traceInfo = OMEStackTrace.BriefStackTrace(st, 0); //ilaevel is stack Frame 
            }

            string traceMessage = oEx.ErrorCode;
            if (oEx.innerException != null)
            {
                traceMessage += Environment.NewLine + oEx.innerException;
            }

            traceMessage += Environment.NewLine + traceInfo;

            lock (m_syncLock)
            {
                m_Logger.Write(traceMessage);
            }
        }
示例#5
0
        public static string HandleException(OMEException objEx)
        {
            string messageFromResourceFile =objEx.ErrorCode;
            if (!m_ExceptionLoggingInfo.IsLoggingEnabled)
            {
                return messageFromResourceFile; 
            }

            if( m_ExceptionLoggingInfo.CriticalityLevel.ToUpper()=="HIGH" )
            {
                if(objEx.criticalityLevel == CriticalityLevel.HIGH )
                {
                  LogException(objEx);
                }
            }
            else if( m_ExceptionLoggingInfo.CriticalityLevel.ToUpper()=="MEDIUM" )
            {
                if (objEx.criticalityLevel == CriticalityLevel.HIGH || objEx.criticalityLevel == CriticalityLevel.MEDIUM) 
                {
                   LogException(objEx);
                }
            }
            else if ( m_ExceptionLoggingInfo.CriticalityLevel.ToUpper() == "LOW" )
            {
                if (objEx.criticalityLevel == CriticalityLevel.HIGH || objEx.criticalityLevel == CriticalityLevel.MEDIUM || objEx.criticalityLevel == CriticalityLevel.MEDIUM || objEx.criticalityLevel == CriticalityLevel.LOW ) 
                {
                   LogException(objEx);
                }
            }
            return messageFromResourceFile; 
        }