Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit db66126

Browse files
committed
Simplify code
1 parent c6ad716 commit db66126

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/GitHub.Api/NewTaskSystem/TaskExtensions.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ public static async Task SafeAwait(this Task source, Action<Exception> handler =
2020
catch (Exception ex)
2121
{
2222
Logging.GetLogger().Error(ex);
23-
if (handler != null)
24-
handler(ex);
25-
else
23+
if (handler == null)
2624
throw;
25+
handler(ex);
2726
}
2827
}
2928

@@ -36,9 +35,9 @@ public static async Task<T> SafeAwait<T>(this Task<T> source, Func<Exception, T>
3635
catch (Exception ex)
3736
{
3837
Logging.GetLogger().Error(ex);
39-
if (handler != null)
40-
return handler(ex);
41-
throw;
38+
if (handler == null)
39+
throw;
40+
return handler(ex);
4241
}
4342
}
4443

@@ -51,10 +50,9 @@ public static async Task StartAwait(this ITask source, Action<Exception> handler
5150
catch (Exception ex)
5251
{
5352
Logging.GetLogger().Error(ex);
54-
if (handler != null)
55-
handler(ex);
56-
else
53+
if (handler == null)
5754
throw;
55+
handler(ex);
5856
}
5957
}
6058

@@ -67,9 +65,9 @@ public static async Task<T> StartAwait<T>(this ITask<T> source, Func<Exception,
6765
catch (Exception ex)
6866
{
6967
Logging.GetLogger().Error(ex);
70-
if (handler != null)
71-
return handler(ex);
72-
throw;
68+
if (handler == null)
69+
throw;
70+
return handler(ex);
7371
}
7472
}
7573

0 commit comments

Comments
 (0)