Skip to content

Commit

Permalink
Fix return type of WaitWithUnwrappedExceptions to match Wait
Browse files Browse the repository at this point in the history
(Each overload matches the return type of the corresponding Wait
overload.)
  • Loading branch information
jskeet committed Nov 7, 2018
1 parent 845b3cf commit 7a4e920
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Google.Api.Gax/TaskExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ public static void WaitWithUnwrappedExceptions(this Task task)
/// <param name="task">The task to wait for.</param>
/// <param name="timeout">A TimeSpan that represents the number of milliseconds to wait, or
/// -1 milliseconds to wait indefinitely.</param>
public static void WaitWithUnwrappedExceptions(this Task task, TimeSpan timeout)
public static bool WaitWithUnwrappedExceptions(this Task task, TimeSpan timeout)
{
try
{
task.Wait(timeout);
return task.Wait(timeout);
}
catch (AggregateException e)
{
Expand All @@ -72,6 +72,7 @@ public static void WaitWithUnwrappedExceptions(this Task task, TimeSpan timeout)
// but let's handle it relatively gracefully.
// Using ExceptionDispatchInfo to keep the original exception stack trace.
ExceptionDispatchInfo.Capture(e.InnerExceptions.FirstOrDefault() ?? e).Throw();
throw new InvalidOperationException("Only present to keep the compiler happy");
}
}

Expand All @@ -82,11 +83,11 @@ public static void WaitWithUnwrappedExceptions(this Task task, TimeSpan timeout)
/// <param name="task">The task to wait for.</param>
/// <param name="millisecondsTimeout">The number of milliseconds to wait, or
/// -1 to wait indefinitely.</param>
public static void WaitWithUnwrappedExceptions(this Task task, int millisecondsTimeout)
public static bool WaitWithUnwrappedExceptions(this Task task, int millisecondsTimeout)
{
try
{
task.Wait(millisecondsTimeout);
return task.Wait(millisecondsTimeout);
}
catch (AggregateException e)
{
Expand All @@ -95,6 +96,7 @@ public static void WaitWithUnwrappedExceptions(this Task task, int millisecondsT
// but let's handle it relatively gracefully.
// Using ExceptionDispatchInfo to keep the original exception stack trace.
ExceptionDispatchInfo.Capture(e.InnerExceptions.FirstOrDefault() ?? e).Throw();
throw new InvalidOperationException("Only present to keep the compiler happy");
}
}

Expand All @@ -106,11 +108,11 @@ public static void WaitWithUnwrappedExceptions(this Task task, int millisecondsT
/// <param name="millisecondsTimeout">The number of milliseconds to wait, or
/// -1 to wait indefinitely.</param>
/// <param name="cancellationToken">A cancellation token to observe while waiting for the task to complete</param>
public static void WaitWithUnwrappedExceptions(this Task task, int millisecondsTimeout, CancellationToken cancellationToken)
public static bool WaitWithUnwrappedExceptions(this Task task, int millisecondsTimeout, CancellationToken cancellationToken)
{
try
{
task.Wait(millisecondsTimeout, cancellationToken);
return task.Wait(millisecondsTimeout, cancellationToken);
}
catch (AggregateException e)
{
Expand All @@ -119,6 +121,7 @@ public static void WaitWithUnwrappedExceptions(this Task task, int millisecondsT
// but let's handle it relatively gracefully.
// Using ExceptionDispatchInfo to keep the original exception stack trace.
ExceptionDispatchInfo.Capture(e.InnerExceptions.FirstOrDefault() ?? e).Throw();
throw new InvalidOperationException("Only present to keep the compiler happy");
}
}

Expand Down

0 comments on commit 7a4e920

Please sign in to comment.