Пример #1
0
        /// <summary>
        /// Saves the exception and all inner exceptions to the database
        /// </summary>
        /// <param name="e">Exception that was thrown</param>
        private static void LogError(System.Exception e)
        {
            //if the database connection is not down
            System.Exception connectionError;

            if (DbObjects.Data.Control.TestConnection(out connectionError))
            {
                DbObjects.Business.Error parent = null;

                //traverse down inner exceptions
                while (e != null)
                {
                    //all app errors are inner exceptions to a HttpUnhandledException so we want to ignore the first one
                    if (e.GetType().Name != "HttpUnhandledException")
                    {
                        DbObjects.Business.Error child = DbObjects.Business.Error.FromException(e);
                        child.Save();

                        if (parent != null)
                        {
                            parent.AddInnerError(child);
                        }

                        parent = child;
                    }

                    e = e.InnerException;
                }
            }
            else
            {
                ///TODO: output error to alternative souce along with connectionError
            }
        }
Пример #2
0
        private void BindError()
        {
            DbObjects.Business.Error error = SelectedError;

            lblName.Text       = error.Name;
            lblMessage.Text    = error.Message;
            lblStackTrace.Text = error.StrackTrace.Replace("<br />", "</li><li>");

            List <DbObjects.Business.Error> innerErrors = new List <DbObjects.Business.Error>();

            while (error.InnerError != null)
            {
                error = error.InnerError;
                innerErrors.Add(error);
            }

            rptInnerErrors.DataSource = innerErrors;
            rptInnerErrors.DataBind();
        }