/// <summary>
        /// Creates instance of <see cref="ErrorWindow"/> for all other factory Report methods will result in a call to this one
        /// </summary>
        /// <param name="message">Which message to display</param>
        /// <param name="stackTrace">The associated stack trace</param>
        /// <param name="policy">In which situations the stack trace should be appended to the message</param>
        private static void Report(string message, string stackTrace, ErrorShowStackTrace policy)
        {
            string errorDetails = string.Empty;

            if (NavigationApp.ErrorPolicy == ErrorShowStackTrace.Always ||
                policy == ErrorShowStackTrace.Always ||
                policy == ErrorShowStackTrace.OnlyWhenDebugging && Debugger.IsAttached)
            {
                errorDetails = stackTrace ?? string.Empty;
            }
            if (Debugger.IsAttached)
            {
                DebugManager.LogError(message + Environment.NewLine + stackTrace);
            }

            var ew = new ErrorWindow(message, errorDetails);

            ew.ShowDialog();
        }
Exemple #2
0
        /////<summary>
        ///// gets or sets an UI element that supports error reporting, e.g. MainWindow, MainPage
        /////</summary>
        //public IElementSupportsErrorReporting ErrorReportingElement { get; set; }
        ///// <summary>
        ///// Occurs when an unhandled exception is thrown
        ///// </summary>
        //public event EventHandler<UnhandledExceptionReportedEventArgs> UnhandledExceptionReported;

        /// <summary>
        /// Reports an exception in error dialog window using the ErrorReportingElement
        /// </summary>
        /// <param name="exception"></param>
        public void ReportError(Exception exception)
        {
            ErrorWindow.Report(exception, ErrorPolicy);
            //var index = 1;
            //var message = exception.Message;
            //var stack = string.Format("Error #{0}: {1}\n{2}", index++, message, exception.StackTrace);
            //var stackTrace = new StringBuilder(stack);
            //exception = exception.InnerException;
            //while (exception != null)
            //{
            //    message = exception.Message;
            //    stack = string.Format("\nError #{0}: {1}\n{2}", index++, message, exception.StackTrace);
            //    stackTrace.Append(stack);
            //    exception = exception.InnerException;
            //}

            //if (this.ErrorReportingElement != null)
            //{
            //    this.ErrorReportingElement.ShowErrorDialog(message, stackTrace.ToString());
            //}
            //SL
            //System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight Application " + message + stackTrace.ToString() + "\");");
        }