Пример #1
0
 public static Guid A(Exception ex, Endeme actions, GuiActionTrace gat)
 {
     return(A(ex, actions, _eventSource, gat));
 }                                                                                                                    /// <param name="level">level of error: 18 if generally good for programmer warnings, 21 is good for critical user level errors</param>
Пример #2
0
        }                                                                                                                    /// <param name="level">level of error: 18 if generally good for programmer warnings, 21 is good for critical user level errors</param>

        public static Guid A(Exception ex, GuiActionTrace gat)
        {
            return(A(ex, _actions, _eventSource, gat));
        }                                                                                                     /// <param name="level">level of error: 18 if generally good for programmer warnings, 21 is good for critical user level errors</param><param name="actions">D)atalog, E)ventlog, G)ATtrace, I)gnore, eM)ail, N)one, P)ause, S)quawk, T)hrows</param>
Пример #3
0
        // ----------------------------------------------------------------------------------------
        /// <!-- A -->
        /// <summary>
        ///      Provides a breakpoint in development and throws an exception in production
        /// </summary>
        /// <param name="e">exception</param>
        /// <param name="actions">bug action</param>
        /// <returns>The id in the database if sent to the database</returns>
        public static Guid A(Exception ex, Endeme actions, EventSourceCreationData eventSource
                             , GuiActionTrace gat)
        {
            if (_exceptionAct == null)
            {
                FillExceptionAct();
            }


            // --------------------------------------------------------------------------
            //  Handle missing exception actions with a default Squawk-Log-Pause
            // --------------------------------------------------------------------------
            if (_actions == null)
            {
                _actions = "" + Squawk + EventLog + Pauses;
            }
            if (actions == null)
            {
                actions = _actions;
            }


            // --------------------------------------------------------------------------
            //  Handle missing event log operational data by complaining
            // --------------------------------------------------------------------------
            if (eventSource == null)
            {
                throw new NoNullAllowedException("EventSourceCreationData is null!"
                                                 + "\r\n" + " You may have to add code something like this before running Throw:"
                                                 + "\r\n" + "    Throw.EventSourceBuild(\"MyProj\", \"MyProLog\");"
                                                 );
            }


            Guid   guid   = Guid.Empty;
            string strGat = "";


            // --------------------------------------------------------------------------
            //   Prepare message text
            // --------------------------------------------------------------------------
            string msg = "";

            if (ex.InnerException != null)
            {
                msg = ex.InnerException.GetType().ToString()
                      + "\r\n" + ex.InnerException.Message
                      + "\r\n"
                      + "\r\n" + ex.Message;
            }
            else
            {
                msg = ex.GetType().ToString() + " - " + ex.Message;
            }


            // --------------------------------------------------------------------------
            //   Determine action level
            // --------------------------------------------------------------------------
            //int idx = actions.ToString().IndexOf('L');
            //if (idx < 0)  idx = 11;
            //int actionLevel;
            //if (idx >= 0)  actionLevel = 22 - idx;
            //else  actionLevel = 20;  // default action level, action level is a callable/programmable cutoff point
            //// N is a mandatory cutoff point


            // --------------------------------------------------------------------------
            //  This is how to do it with an endeme
            // --------------------------------------------------------------------------
            if (msg != _lastMessage && // don't keep spewing out the same messages
                msg != _prevMessage &&
                !Regex.IsMatch(msg, "Deadlock victim", RegexOptions.IgnoreCase))     // I don't want to hear about deadlock victims
            {
                char[] act = actions.ToCharArray();
                bool   run = true;
                for (int i = 0; run && i < act.Length; ++i)
                {
                    switch (act[i])
                    {
                    //case DataLog: guid = SendToDatabase("CodeWhite", msg, strGat); break;
                    case EventLog: SendToActionLog(msg, eventSource, strGat); break;

                    case Ignore: break;

                    case Email: break;

                    case None: run = false; break;

                    case Pauses: Pause(); break;     // set a breakpoint here

                    case Squawk: MessageBox.Show(msg); break;

                    case Throws: throw ex;     // turn this on in production and make sure it's handled
                    }
                }
            }
            _prevMessage = _lastMessage;
            _lastMessage = msg;


            return(guid);
        }