From 32ac169e1e5d33149d692430d8195ac87788d84d Mon Sep 17 00:00:00 2001 From: Thomas Levesque Date: Thu, 13 Dec 2018 16:59:41 +0100 Subject: [PATCH 1/2] Update specs to document the new behavior --- tests/FakeItEasy.Specs/UserCallbackExceptionSpecs.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tests/FakeItEasy.Specs/UserCallbackExceptionSpecs.cs b/tests/FakeItEasy.Specs/UserCallbackExceptionSpecs.cs index e84a05f5b..31a3ec7de 100644 --- a/tests/FakeItEasy.Specs/UserCallbackExceptionSpecs.cs +++ b/tests/FakeItEasy.Specs/UserCallbackExceptionSpecs.cs @@ -362,7 +362,7 @@ public void ExceptionInExceptionFactory(IFoo fake, Exception exception) } [Scenario] - public void ExceptionInCallback(IFoo fake, Exception exception) + public void ExceptionInCallbackIsNotWrapped(IFoo fake, Exception exception) { "Given a fake" .x(() => fake = A.Fake()); @@ -373,14 +373,8 @@ public void ExceptionInCallback(IFoo fake, Exception exception) "When the configured method is called" .x(() => exception = Record.Exception(() => fake.Bar(0))); - "Then a UserCallbackException should be thrown" - .x(() => exception.Should().BeAnExceptionOfType()); - - "And its message should describe where the exception was thrown from" - .x(() => exception.Message.Should().Be("Callback threw an exception. See inner exception for details.")); - - "And the inner exception should be the original exception" - .x(() => exception.InnerException.Should().BeAnExceptionOfType().Which.Message.Should().Be("Oops")); + "Then the original exception should be thrown" + .x(() => exception.Should().BeAnExceptionOfType().Which.Message.Should().Be("Oops")); } private static bool ThrowException() From a9a07bf04cdc8afff3442d40fad8d873cd96422c Mon Sep 17 00:00:00 2001 From: Thomas Levesque Date: Thu, 13 Dec 2018 17:00:06 +0100 Subject: [PATCH 2/2] Don't wrap exceptions thrown by Invokes callbacks --- src/FakeItEasy/Configuration/BuildableCallRule.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/FakeItEasy/Configuration/BuildableCallRule.cs b/src/FakeItEasy/Configuration/BuildableCallRule.cs index f31ea1b50..1eda6a138 100644 --- a/src/FakeItEasy/Configuration/BuildableCallRule.cs +++ b/src/FakeItEasy/Configuration/BuildableCallRule.cs @@ -102,14 +102,7 @@ public virtual void Apply(IInterceptedFakeObjectCall fakeObjectCall) foreach (var action in this.Actions) { - try - { - action.Invoke(fakeObjectCall); - } - catch (Exception ex) when (!(ex is FakeConfigurationException)) - { - throw new UserCallbackException(ExceptionMessages.UserCallbackThrewAnException("Callback"), ex); - } + action.Invoke(fakeObjectCall); } this.applicator.Invoke(fakeObjectCall);