/// <summary> /// Creates a new Error Window given an exception. The exception is converted onto a message using /// <see cref="ConvertExceptionToMessage"/> /// /// <param name="policy">When to display the stack trace, see <see cref="StackTracePolicy"/></param> /// </summary> public static void CreateNew(Exception exception, StackTracePolicy policy) { string fullStackTrace = exception.StackTrace; // Account for nested exceptions Exception innerException = exception.InnerException; while (innerException != null) { fullStackTrace += "\nCaused by: " + exception.Message + "\n\n" + exception.StackTrace; innerException = innerException.InnerException; } CreateNew(ConvertExceptionToMessage(exception), fullStackTrace, policy); }
/// <summary> /// All other factory methods will result in a call to this one. /// </summary> /// <param name="message">The message to display</param> /// <param name="stackTrace">The associated stack trace</param> /// <param name="policy">The situations in which the stack trace should be appended to the message</param> private static void CreateNew(string message, string stackTrace, StackTracePolicy policy) { string errorDetails = string.Empty; if (policy == StackTracePolicy.Always || policy == StackTracePolicy.OnlyWhenDebuggingOrRunningLocally && IsRunningUnderDebugOrLocalhost) { errorDetails = stackTrace ?? string.Empty; } ErrorWindow window = new ErrorWindow(message, errorDetails); window.Show(); }
/// <summary> /// Creates a new Error Window given an exception. The exception is converted onto a message using /// <see cref="ConvertExceptionToMessage"/> /// /// <param name="policy">When to display the stack trace, see <see cref="StackTracePolicy"/></param> /// </summary> public static void CreateNew(Exception exception, StackTracePolicy policy) { string fullStackTrace = exception.StackTrace; // Account for nested exceptions Exception innerException = exception.InnerException; while (innerException != null) { fullStackTrace += "\nCaused by: " + innerException.Message + "\n\n" + innerException.StackTrace; innerException = innerException.InnerException; } CreateNew(ConvertExceptionToMessage(exception), fullStackTrace, policy); }
/// <summary> /// Creates a new Error Window given an exception. /// The exception is converted into a message using <see cref="ConvertExceptionToMessage"/>. /// </summary> /// <param name="exception">The exception to display.</param> /// <param name="policy">When to display the stack trace, see <see cref="StackTracePolicy"/>.</param> public static void CreateNew(Exception exception, StackTracePolicy policy) { if (exception == null) { throw new ArgumentNullException("exception"); } string fullStackTrace = exception.StackTrace; // Account for nested exceptions Exception innerException = exception.InnerException; while (innerException != null) { fullStackTrace += "\n" + string.Format(System.Globalization.CultureInfo.CurrentUICulture, ErrorResources.ErrorWindowInnerException, innerException.Message) + "\n\n" + innerException.StackTrace; innerException = innerException.InnerException; } CreateNew(ConvertExceptionToMessage(exception), fullStackTrace, policy); }
public static void CreateNew(Exception exception, StackTracePolicy policy) { if (exception == null) { throw new ArgumentNullException("exception"); } string fullStackTrace = exception.StackTrace; // Account for nested exceptions Exception innerException = exception.InnerException; while (innerException != null) { fullStackTrace += "\nCaused by: " + exception.Message + "\n\n" + exception.StackTrace; innerException = innerException.InnerException; } CreateNew(exception.Message, fullStackTrace, policy); }
/// <summary> /// Creates a new Error Window given an error message. /// </summary> /// <param name="message">The message to display.</param> /// <param name="policy">When to display the stack trace, see <see cref="StackTracePolicy"/>.</param> public static void CreateNew(string message, StackTracePolicy policy) { CreateNew(message, new StackTrace().ToString(), policy); }
/// <summary> /// All other factory 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 CreateNew(string message, string stackTrace, StackTracePolicy policy) { string errorDetails = string.Empty; ErrorWindow window; if (policy == StackTracePolicy.Always || policy == StackTracePolicy.OnlyWhenDebuggingOrRunningLocally && IsRunningUnderDebugOrLocalhost) { errorDetails = stackTrace ?? string.Empty; window = new ErrorWindow(message, errorDetails); } else { window = new ErrorWindow(message, errorDetails); window.ErrorTextBox.Visibility = Visibility.Collapsed; } window.Show(); }
/// <summary> /// Creates a new Error Window given an error message. /// </summary> /// <param name="message">The message to display.</param> /// <param name="policy">When to display the stack trace, see <see cref="StackTracePolicy"/>.</param> public static ErrorWindow CreateNew(string message, StackTracePolicy policy) { return CreateNew(message, new StackTrace().ToString(), policy); }