Unwrap inner exceptions when showing exception

This commit is contained in:
pizzaboxer 2023-08-06 14:32:58 +01:00
parent 53ccac4b37
commit f617700457
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
2 changed files with 15 additions and 4 deletions

View File

@ -6,7 +6,7 @@
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:local="clr-namespace:Bloxstrap.UI.Elements.Dialogs" xmlns:local="clr-namespace:Bloxstrap.UI.Elements.Dialogs"
mc:Ignorable="d" mc:Ignorable="d"
Width="480" Width="540"
MinHeight="0" MinHeight="0"
SizeToContent="Height" SizeToContent="Height"
Background="{ui:ThemeResource ApplicationBackgroundBrush}" Background="{ui:ThemeResource ApplicationBackgroundBrush}"

View File

@ -22,10 +22,8 @@ namespace Bloxstrap.UI.Elements.Dialogs
InitializeComponent(); InitializeComponent();
Title = RootTitleBar.Title = $"{App.ProjectName} Exception"; Title = RootTitleBar.Title = $"{App.ProjectName} Exception";
ErrorRichTextBox.Selection.Text = $"{exception.GetType()}: {exception.Message}";
if (innerException is not null) AddException(exception);
ErrorRichTextBox.Selection.Text += $"\n\n===== Inner Exception =====\n{innerException.GetType()}: {innerException.Message}";
if (!App.Logger.Initialized) if (!App.Logger.Initialized)
LocateLogFileButton.Content = "Copy log contents"; LocateLogFileButton.Content = "Copy log contents";
@ -66,5 +64,18 @@ namespace Bloxstrap.UI.Elements.Dialogs
PInvoke.FlashWindow((HWND)hWnd, true); 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);
}
} }
} }