diff --git a/Bloxstrap/UI/Elements/Dialogs/ConnectivityDialog.xaml.cs b/Bloxstrap/UI/Elements/Dialogs/ConnectivityDialog.xaml.cs index b34a905..c16025a 100644 --- a/Bloxstrap/UI/Elements/Dialogs/ConnectivityDialog.xaml.cs +++ b/Bloxstrap/UI/Elements/Dialogs/ConnectivityDialog.xaml.cs @@ -16,17 +16,12 @@ namespace Bloxstrap.UI.Elements.Dialogs { public ConnectivityDialog(string targetName, string description, Exception exception) { - Exception? innerException = exception.InnerException; - InitializeComponent(); TitleTextBlock.Text = $"{App.ProjectName} is unable to connect to {targetName}"; DescriptionTextBlock.Text = description; - ErrorRichTextBox.Selection.Text = $"{exception.GetType()}: {exception.Message}"; - - if (innerException is not null) - ErrorRichTextBox.Selection.Text += $"\n\n===== Inner Exception =====\n{innerException.GetType()}: {innerException.Message}"; + AddException(exception); CloseButton.Click += delegate { @@ -41,5 +36,18 @@ namespace Bloxstrap.UI.Elements.Dialogs PInvoke.FlashWindow((HWND)hWnd, true); }; } + + private void AddException(Exception exception, bool inner = false) + { + if (!inner) + ErrorRichTextBox.Selection.Text = $"{exception.GetType()}: {exception.Message}"; + + if (exception.InnerException is null) + return; + + ErrorRichTextBox.Selection.Text += $"\n\n[Inner Exception]\n{exception.InnerException.GetType()}: {exception.InnerException.Message}"; + + AddException(exception.InnerException, true); + } } }