Skip to content

Commit

Permalink
reworked how exceptions were displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
4sval committed Aug 12, 2022
1 parent 61c1c67 commit f8e929b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CUE4Parse
7 changes: 4 additions & 3 deletions FModel/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ public static class Constants
public static readonly FGuid ZERO_GUID = new(0U);

public const string WHITE = "#DAE5F2";
public const string GRAY = "#BBBBBB";
public const string RED = "#E06C75";
public const string GREEN = "#98C379";
public const string YELLOW = "#E5C07B";
public const string BLUE = "#528BCC";

public const string ISSUE_LINK = "https://github.com/iAmAsval/FModel/issues/new/choose";
public const string DONATE_LINK = "https://fmodel.app/donate";
public const string DISCORD_LINK = "https://fmodel.app/discord";
public const string DONATE_LINK = "https://fmodel.app/donate?utm_source=fmodel&utm_medium=app&utm_campaign=donations";
public const string DISCORD_LINK = "https://fmodel.app/discord?utm_source=fmodel&utm_medium=app&utm_campaign=discord-server";

public const string _FN_LIVE_TRIGGER = "fortnite-live.manifest";
public const string _VAL_LIVE_TRIGGER = "valorant-live.manifest";

public const string _NO_PRESET_TRIGGER = "Hand Made";
}
}
36 changes: 32 additions & 4 deletions FModel/ViewModels/ThreadWorkerViewModel.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -41,6 +41,10 @@ public CancellationTokenSource CurrentCancellationTokenSource

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()
{
Expand Down Expand Up @@ -99,8 +103,32 @@ private async Task ProcessQueues()
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;
}
}
Expand All @@ -115,4 +143,4 @@ public void SignalOperationInProgress()
StatusChangeAttempted = true;
StatusChangeAttempted = false;
}
}
}

0 comments on commit f8e929b

Please sign in to comment.