mirror of
https://github.com/4sval/FModel.git
synced 2026-09-26 19:17:46 -05:00
reworked how exceptions were displayed
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using FModel.Extensions;
|
||||
using FModel.Framework;
|
||||
using FModel.Services;
|
||||
using FModel.Views.Resources.Controls;
|
||||
@@ -41,6 +41,10 @@ public class ThreadWorkerViewModel : ViewModel
|
||||
|
||||
private ApplicationViewModel _applicationView => ApplicationService.ApplicationView;
|
||||
private readonly AsyncQueue<Action<CancellationToken>> _jobs;
|
||||
private const string _at = " at ";
|
||||
private const char _dot = '.';
|
||||
private const char _colon = ':';
|
||||
private const string _gray = "#999";
|
||||
|
||||
public ThreadWorkerViewModel()
|
||||
{
|
||||
@@ -99,8 +103,32 @@ public class ThreadWorkerViewModel : ViewModel
|
||||
Log.Error("{Exception}", e);
|
||||
|
||||
FLogger.AppendError();
|
||||
FLogger.AppendText(e.Message, Constants.WHITE, true);
|
||||
FLogger.AppendText(" " + e.StackTrace.SubstringBefore('\n').Trim(), Constants.WHITE, true);
|
||||
if ((e.InnerException ?? e) is { TargetSite.DeclaringType: not null } exception)
|
||||
{
|
||||
if (exception.TargetSite.ToString() == "CUE4Parse.FileProvider.GameFile get_Item(System.String)")
|
||||
{
|
||||
FLogger.AppendText(e.Message, Constants.WHITE, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
var t = exception.GetType();
|
||||
FLogger.AppendText(t.Namespace + _dot, Constants.GRAY);
|
||||
FLogger.AppendText(t.Name, Constants.WHITE);
|
||||
FLogger.AppendText(_colon + " ", Constants.GRAY);
|
||||
FLogger.AppendText(exception.Message, Constants.RED, true);
|
||||
|
||||
FLogger.AppendText(_at, _gray);
|
||||
FLogger.AppendText(exception.TargetSite.DeclaringType.FullName + _dot, Constants.GRAY);
|
||||
FLogger.AppendText(exception.TargetSite.Name, Constants.YELLOW);
|
||||
|
||||
var parameters = new StringBuilder();
|
||||
foreach (var parameter in exception.TargetSite.GetParameters())
|
||||
{
|
||||
parameters.Append(parameter.ParameterType.Name + " " + parameter.Name);
|
||||
}
|
||||
FLogger.AppendText("(" + string.Join(", ", parameters) + ")", Constants.GRAY, true);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -115,4 +143,4 @@ public class ThreadWorkerViewModel : ViewModel
|
||||
StatusChangeAttempted = true;
|
||||
StatusChangeAttempted = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user