Пример #1
0
        internal ExecutionFlow Report(Exception exception, ExceptionThread exceptionThread)
        {
            try
            {
                Logger.Trace("Starting to generate a bug report for the exception.");
                var serializableException = new SerializableException(exception);
                var report = new Report(serializableException);

                var handler = ProcessingException;
                if (handler != null)
                {
                    Logger.Trace("Notifying the user before handling the exception.");

                    // Allowing user to add any custom information to the report
                    handler(exception, report);
                }

                var uiDialogResult = UISelector.DisplayBugReportUI(exceptionThread, serializableException, report);
                if (uiDialogResult.Report == SendReport.Send)
                {
                    this.CreateReportZip(serializableException, report);
                }

                return uiDialogResult.Execution;
            }
            catch (Exception ex)
            {
                Logger.Error("An exception occurred during bug report generation process. See the inner exception for details.", ex);
                return ExecutionFlow.BreakExecution; // Since an internal exception occured
            }
        }
Пример #2
0
        internal ExecutionFlow Report(Exception exception, ExceptionThread exceptionThread)
        {
            try
            {
                Logger.Trace("Starting to generate a bug report for the exception.");
                var serializableException = new SerializableException(exception);
                var report = new Report(serializableException);

                var handler = ProcessingException;
                if (handler != null)
                {
                    Logger.Trace("Notifying the user before handling the exception.");

                    // Allowing user to add any custom information to the report
                    handler(exception, report);
                }

                //var uiDialogResult = UISelector.DisplayBugReportUI(exceptionThread, serializableException, report);
                //if (uiDialogResult.Report == SendReport.Send)
                //{
                //	this.CreateReportZip(serializableException, report);
                //}

                //return uiDialogResult.Execution;
            }
            catch (Exception ex)
            {
                Logger.Error("An exception occurred during bug report generation process. See the inner exception for details.", ex);
                //return ExecutionFlow.BreakExecution; // Since an internal exception occured
            }
            return(default(ExecutionFlow)); //  uiDialogResult.Execution;
        }
Пример #3
0
        internal ExecutionFlow Report(Exception exception, ExceptionThread exceptionThread)
        {
            try
            {
                Logger.Trace("Starting to generate a bug report for the exception.");
                var serializableException = new SerializableException(exception);
                var report = new Report(serializableException);

                var handler = ProcessingException;
                if (handler != null)
                {
                    Logger.Trace("Notifying the user before handling the exception.");

                    // Allowing user to add any custom information to the report
                    handler(exception, report);
                }

                var uiDialogResult = UISelector.DisplayBugReportUI(exceptionThread, serializableException, report);
                if (uiDialogResult.Report == SendReport.Send)
                {
                    this.CreateReportZip(serializableException, report);
                }

                // If NBug is configured not to delay error reporting and user did not select to exit the app immediately,
                // start dispatching the bug report right away
                if (!Settings.DeferredReporting)
                {
                    new NBug.Core.Submission.Dispatcher();
                }

                return(uiDialogResult.Execution);
            }
            catch (Exception ex)
            {
                Logger.Error("An exception occurred during bug report generation process. See the inner exception for details.", ex);
                return(ExecutionFlow.BreakExecution);                // Since an internal exception occured
            }
        }
Пример #4
0
        internal ExecutionFlow Report(Exception exception, ExceptionThread exceptionThread)
        {
            try
            {
                Logger.Trace("Starting to generate a bug report for the exception.");
                var serializableException = new SerializableException(exception);
                var report = new Report(serializableException);

                var handler = ProcessingException;
                if (handler != null)
                {
                    Logger.Trace("Notifying the user before handling the exception.");

                    // Allowing user to add any custom information to the report
                    handler(exception, report);
                }

                var uiDialogResult = UISelector.DisplayBugReportUI(exceptionThread, serializableException, report);
                if (uiDialogResult.Report == SendReport.Send)
                {
                    this.CreateReportZip(serializableException, report);
                }

                // If NBug is configured not to delay error reporting and user did not select to exit the app immediately,
                // start dispatching the bug report right away
                if (!Settings.DeferredReporting && uiDialogResult.Execution == ExecutionFlow.ContinueExecution)
                {
                    new NBug.Core.Submission.Dispatcher();
                }

                return uiDialogResult.Execution;
            }
            catch (Exception ex)
            {
                Logger.Error("An exception occurred during bug report generation process. See the inner exception for details.", ex);
                return ExecutionFlow.BreakExecution; // Since an internal exception occured
            }
        }
Пример #5
0
		internal static UIDialogResult DisplayBugReportUI(ExceptionThread exceptionThread, SerializableException serializableException, Report report)
		{
			if (exceptionThread == ExceptionThread.Task)
			{
				// Do not interfere with the default behaviour for continuation on background thread exceptions. Just log and send'em (no UI...)
				return new UIDialogResult(ExecutionFlow.ContinueExecution, SendReport.Send);
			}
			else if (Settings.UIMode == UIMode.Auto)
			{
				// First of, test to see if the call is from an UI thread and if so, use the same UI type (WinForms, WPF, etc.)
				if (exceptionThread == ExceptionThread.UI_WinForms)
				{
					return WinFormsUI.ShowDialog(UIMode.Minimal, serializableException, report);
				}
				else if (exceptionThread == ExceptionThread.UI_WPF)
				{
					return WPFUI.ShowDialog(UIMode.Minimal, serializableException, report);
				}
				else if (exceptionThread == ExceptionThread.Main)
				{
					// If the call is not from a non-UI thread like the main app thread, it may be from the current appdomain but
					// the application may still be using an UI. Or it may be coming from an exception filter where UI type is undefined yet.
					switch (DiscoverUI())
					{
						case UIProvider.WinForms:
							return WinFormsUI.ShowDialog(UIMode.Minimal, serializableException, report);
						case UIProvider.WPF:
							return WPFUI.ShowDialog(UIMode.Minimal, serializableException, report);
						case UIProvider.Console:
							return ConsoleUI.ShowDialog(UIMode.Minimal, serializableException, report);
						default:
							throw new NBugRuntimeException("UISelector.DiscoverUI() returned an invalid UI type.");
					}
				}
				else
				{
					throw new NBugRuntimeException("Parameter supplied for '" + typeof(ExceptionThread).Name + "' is not valid.");
				}
			}
			else if (Settings.UIMode == UIMode.None)
			{
				// Do not display an UI for UIMode.None
				if (Settings.ExitApplicationImmediately)
				{
					return new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.Send);
				}
				else
				{
					return new UIDialogResult(ExecutionFlow.ContinueExecution, SendReport.Send);
				}
			}
			else if (Settings.UIProvider == UIProvider.Console)
			{
				return ConsoleUI.ShowDialog(Settings.UIMode, serializableException, report);
			}
			else if (Settings.UIProvider == UIProvider.WinForms)
			{
				return WinFormsUI.ShowDialog(Settings.UIMode, serializableException, report);
			}
			else if (Settings.UIProvider == UIProvider.WPF)
			{
				return WPFUI.ShowDialog(Settings.UIMode, serializableException, report);
			}
			else if (Settings.UIProvider == UIProvider.Auto)
			{
				// In this case, UIProvider = Auto & UIMode != Auto so just discover the UI provider and use the selected UI mode
				switch (DiscoverUI())
				{
					case UIProvider.WinForms:
						return WinFormsUI.ShowDialog(Settings.UIMode, serializableException, report);
					case UIProvider.WPF:
						return WPFUI.ShowDialog(Settings.UIMode, serializableException, report);
					case UIProvider.Console:
						return ConsoleUI.ShowDialog(Settings.UIMode, serializableException, report);
					default:
						throw new NBugRuntimeException("UISelector.DiscoverUI() returned an invalid UI type.");
				}
			}
			else
			{
				throw NBugConfigurationException.Create(() => Settings.UIProvider, "Parameter supplied for settings property is invalid.");
			}
		}
Пример #6
0
        internal static UIDialogResult DisplayBugReportUI(ExceptionThread exceptionThread,
                                                          SerializableException serializableException, Report report)
        {
            if (exceptionThread == ExceptionThread.Task)
            {
                // Do not interfere with the default behaviour for continuation on background thread exceptions. Just log and send'em (no UI...)
                return(new UIDialogResult(ExecutionFlow.ContinueExecution, SendReport.Send));
            }
            if (Settings.UIMode == UIMode.Auto)
            {
                // First of, test to see if the call is from an UI thread and if so, use the same UI type (WinForms, WPF, etc.)
                if (exceptionThread == ExceptionThread.UI_WinForms)
                {
                    return(WinFormsUI.ShowDialog(UIMode.Minimal, serializableException, report));
                }
                if (exceptionThread == ExceptionThread.UI_WPF)
                {
                    return(WPFUI.ShowDialog(UIMode.Minimal, serializableException, report));
                }
                if (exceptionThread == ExceptionThread.Main)
                {
                    // If the call is not from a non-UI thread like the main app thread, it may be from the current appdomain but
                    // the application may still be using an UI. Or it may be coming from an exception filter where UI type is undefined yet.
                    switch (DiscoverUI())
                    {
                    case UIProvider.WinForms:
                        return(WinFormsUI.ShowDialog(UIMode.Minimal, serializableException, report));

                    case UIProvider.WPF:
                        return(WPFUI.ShowDialog(UIMode.Minimal, serializableException, report));

                    case UIProvider.Console:
                        return(ConsoleUI.ShowDialog(UIMode.Minimal, serializableException, report));

                    case UIProvider.Custom:
                        return(CustomUI.ShowDialog(UIMode.Minimal, serializableException, report));

                    default:
                        throw new NBugRuntimeException("UISelector.DiscoverUI() returned an invalid UI type.");
                    }
                }
                throw new NBugRuntimeException(string.Format("Parameter supplied for '{0}' is not valid.",
                                                             typeof(ExceptionThread).Name));
            }
            if (Settings.UIMode == UIMode.None)
            {
                // Do not display an UI for UIMode.None
                if (Settings.ExitApplicationImmediately)
                {
                    return(new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.Send));
                }
                return(new UIDialogResult(ExecutionFlow.ContinueExecution, SendReport.Send));
            }
            if (Settings.UIProvider == UIProvider.Console)
            {
                return(ConsoleUI.ShowDialog(Settings.UIMode, serializableException, report));
            }
            if (Settings.UIProvider == UIProvider.WinForms)
            {
                return(WinFormsUI.ShowDialog(Settings.UIMode, serializableException, report));
            }
            if (Settings.UIProvider == UIProvider.WPF)
            {
                return(WPFUI.ShowDialog(Settings.UIMode, serializableException, report));
            }
            if (Settings.UIProvider == UIProvider.Custom)
            {
                return(CustomUI.ShowDialog(UIMode.Minimal, serializableException, report));
            }
            if (Settings.UIProvider == UIProvider.Auto)
            {
                // In this case, UIProvider = Auto & UIMode != Auto so just discover the UI provider and use the selected UI mode
                switch (DiscoverUI())
                {
                case UIProvider.WinForms:
                    return(WinFormsUI.ShowDialog(Settings.UIMode, serializableException, report));

                case UIProvider.WPF:
                    return(WPFUI.ShowDialog(Settings.UIMode, serializableException, report));

                case UIProvider.Console:
                    return(ConsoleUI.ShowDialog(Settings.UIMode, serializableException, report));

                case UIProvider.Custom:
                    return(CustomUI.ShowDialog(UIMode.Minimal, serializableException, report));

                default:
                    throw new NBugRuntimeException("UISelector.DiscoverUI() returned an invalid UI type.");
                }
            }
            throw NBugConfigurationException.Create(() => Settings.UIProvider,
                                                    "Parameter supplied for settings property is invalid.");
        }