Skip to content

Commit 91d2378

Browse files
authored
Merge branch 'main' into terminal
2 parents 327544c + fa6991b commit 91d2378

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Files.App/Helpers/Application/AppLifecycleHelper.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,12 @@ public static void HandleAppUnhandledException(Exception? ex, bool showToastNoti
267267
ex.Data[Mechanism.HandledKey] = false;
268268
ex.Data[Mechanism.MechanismKey] = "Application.UnhandledException";
269269

270+
SentrySdk.CaptureException(ex, scope =>
271+
{
272+
scope.User.Id = generalSettingsService?.UserId;
273+
scope.Level = SentryLevel.Fatal;
274+
});
275+
270276
formattedException.AppendLine($">>>> HRESULT: {ex.HResult}");
271277

272278
if (ex.Message is not null)

src/Files.App/Utils/Logger/SentryLogger.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using Microsoft.Extensions.Logging;
55
using Sentry;
6+
using Sentry.Protocol;
67

78
namespace Files.App.Utils.Logger
89
{
@@ -21,7 +22,8 @@ public bool IsEnabled(LogLevel logLevel)
2122

2223
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
2324
{
24-
if (exception is null)
25+
// Unhandled exceptions are captured in AppLifecycleHelper.HandleAppUnhandledException
26+
if (exception is null || exception.Data[Mechanism.HandledKey] is false)
2527
return;
2628

2729
var generalSettingsService = Ioc.Default.GetRequiredService<IGeneralSettingsService>();

0 commit comments

Comments
 (0)