Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure all exception rethrows use EDI. #1391

Merged
merged 1 commit into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ internal static class ExceptionHelpers
[DoesNotReturn]
public static void Throw(this Exception exception) => Services.Value.Rethrow(exception);

public static void ThrowIfNotNull(this Exception? exception)
{
if (exception != null)
{
Services.Value.Rethrow(exception);
}
}

private static IExceptionServices Initialize()
{
#pragma warning disable CS0618 // Type or member is obsolete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public bool MoveNext()
done = current.Kind != NotificationKind.OnNext;
}

current.Exception.ThrowIfNotNull();
current.Exception?.Throw();

return current.HasValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public bool MoveNext()
return true;
}

_error.ThrowIfNotNull();
_error?.Throw();

Debug.Assert(_done);

Expand Down
10 changes: 5 additions & 5 deletions Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Blocking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private static TSource FirstOrDefaultInternal<TSource>(IObservable<TSource> sour
consumer.Wait();
}

consumer._error.ThrowIfNotNull();
consumer._error?.Throw();

if (throwOnEmpty && !consumer._hasValue)
{
Expand All @@ -101,7 +101,7 @@ public virtual void ForEach<TSource>(IObservable<TSource> source, Action<TSource
sink.Wait();
}

sink.Error.ThrowIfNotNull();
sink.Error?.Throw();
}

public virtual void ForEach<TSource>(IObservable<TSource> source, Action<TSource, int> onNext)
Expand All @@ -113,7 +113,7 @@ public virtual void ForEach<TSource>(IObservable<TSource> source, Action<TSource
sink.Wait();
}

sink.Error.ThrowIfNotNull();
sink.Error?.Throw();
}

#endregion
Expand Down Expand Up @@ -166,7 +166,7 @@ private static TSource LastOrDefaultInternal<TSource>(IObservable<TSource> sourc
consumer.Wait();
}

consumer._error.ThrowIfNotNull();
consumer._error?.Throw();

if (throwOnEmpty && !consumer._hasValue)
{
Expand Down Expand Up @@ -243,7 +243,7 @@ private static TSource SingleOrDefaultInternal<TSource>(IObservable<TSource> sou
consumer.Wait();
}

consumer._error.ThrowIfNotNull();
consumer._error?.Throw();

if (consumer._hasMoreThanOneElement)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public T GetResult()
return _subject.GetResult();
}

_exception.ThrowIfNotNull();
_exception?.Throw();

return _result!;
}
Expand Down
2 changes: 1 addition & 1 deletion Rx.NET/Source/src/System.Reactive/Subjects/AsyncSubject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ public T GetResult()
e.Wait();
}

_exception.ThrowIfNotNull();
_exception?.Throw();

if (!_hasValue)
{
Expand Down
10 changes: 2 additions & 8 deletions Rx.NET/Source/src/System.Reactive/Subjects/BehaviorSubject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ public T Value
{
CheckDisposed();

if (_exception != null)
{
throw _exception;
}
_exception?.Throw();

return _value;
}
Expand Down Expand Up @@ -121,10 +118,7 @@ public bool TryGetValue([MaybeNullWhen(false)] out T value)
return false;
}

if (_exception != null)
{
throw _exception;
}
_exception?.Throw();

value = _value;
return true;
Expand Down