Skip to content

Commit 99c390e

Browse files
authored
Code Quality: Ignore exceptions in AppLifecycleHelper.HandleAppUnhandledException - part 2 (#16036)
1 parent 4d1b8d6 commit 99c390e

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/Files.Shared/Extensions/SafetyExtensions.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ public static bool IgnoreExceptions(Action action, ILogger? logger = null, Type?
2020
{
2121
if (exceptionToIgnore is null || exceptionToIgnore.IsAssignableFrom(ex.GetType()))
2222
{
23-
logger?.LogInformation(ex, ex.Message);
23+
try
24+
{
25+
logger?.LogInformation(ex, ex.Message);
26+
}
27+
catch { }
2428

2529
return false;
2630
}
@@ -41,7 +45,11 @@ public static async Task<bool> IgnoreExceptions(Func<Task> action, ILogger? logg
4145
{
4246
if (exceptionToIgnore is null || exceptionToIgnore.IsAssignableFrom(ex.GetType()))
4347
{
44-
logger?.LogInformation(ex, ex.Message);
48+
try
49+
{
50+
logger?.LogInformation(ex, ex.Message);
51+
}
52+
catch { }
4553

4654
return false;
4755
}
@@ -60,7 +68,11 @@ public static async Task<bool> IgnoreExceptions(Func<Task> action, ILogger? logg
6068
{
6169
if (exceptionToIgnore is null || exceptionToIgnore.IsAssignableFrom(ex.GetType()))
6270
{
63-
logger?.LogInformation(ex, ex.Message);
71+
try
72+
{
73+
logger?.LogInformation(ex, ex.Message);
74+
}
75+
catch { }
6476

6577
return default;
6678
}
@@ -79,7 +91,11 @@ public static async Task<bool> IgnoreExceptions(Func<Task> action, ILogger? logg
7991
{
8092
if (exceptionToIgnore is null || exceptionToIgnore.IsAssignableFrom(ex.GetType()))
8193
{
82-
logger?.LogInformation(ex, ex.Message);
94+
try
95+
{
96+
logger?.LogInformation(ex, ex.Message);
97+
}
98+
catch { }
8399

84100
return default;
85101
}

0 commit comments

Comments
 (0)