Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Add try catch block to handle exception when finishing ContinueWith #312

Merged
merged 1 commit into from
Jul 16, 2018
Merged
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
17 changes: 14 additions & 3 deletions Assets/Plugins/UniRx/Scripts/Operators/ContinueWith.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,20 @@ public override void OnCompleted()
{
if (seenValue)
{
var v = parent.selector(lastValue);
// dispose source subscription
serialDisposable.Disposable = v.Subscribe(observer);
try
{
var v = parent.selector(lastValue);
// dispose source subscription
serialDisposable.Disposable = v.Subscribe(observer);
}
catch (Exception error)
{
OnError(error);
}
finally
{
Dispose();
Copy link
Contributor

@Js-2nd Js-2nd Jul 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dispose() is always called immediately after serialDisposable.Disposable = v.Subscribe(observer);
This will cancel the subscription if it's not finished immediately.
I think the finally block should be deleted.
@neuecc @sheepbeo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If exception is thrown right before or right at serialDisposable.Disposable = v.Subscribe(observer);
No Dispose() will get called..

}
}
else
{
Expand Down