Skip to content

Commit 179e19d

Browse files
RLittlesIIglennawatson
authored andcommitted
fix: Rethrow exception on RaiseAndSetIfChanged (#2035)
1 parent fda60ac commit 179e19d

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/ReactiveUI.Tests/ReactiveObject/ReactiveObjectTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Collections.Generic;
88
using System.Linq;
99
using System.Reactive.Concurrency;
10+
using System.Reactive.Linq;
1011
using DynamicData;
1112
using Xunit;
1213

@@ -196,5 +197,18 @@ public void ReactiveObjectSmokeTest()
196197
output.AssertAreEqual(output_changing);
197198
results.AssertAreEqual(output);
198199
}
200+
201+
[Fact]
202+
public void ReactiveObjectShouldRethrowException()
203+
{
204+
var fixture = new TestFixture();
205+
var observable = fixture.WhenAnyValue(x => x.IsOnlyOneWord).Skip(1);
206+
observable.Subscribe(x => throw new Exception("This is a test."));
207+
208+
var result = Record.Exception(() => fixture.IsOnlyOneWord = "Two Words");
209+
210+
Assert.IsType<Exception>(result);
211+
Assert.Equal("This is a test.", result.Message);
212+
}
199213
}
200214
}

src/ReactiveUI/ReactiveObject/IReactiveObjectExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,10 @@ internal void NotifyObservable<T>(TSender rxObj, T item, ISubject<T> subject)
391391
if (_thrownExceptions.IsValueCreated)
392392
{
393393
_thrownExceptions.Value.OnNext(ex);
394+
return;
394395
}
396+
397+
throw;
395398
}
396399
}
397400
}

0 commit comments

Comments
 (0)