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

Include original exception in when throwing a BindingException #513

Merged
merged 1 commit into from
Mar 6, 2025
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
4 changes: 2 additions & 2 deletions Reqnroll/ErrorHandling/ErrorProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public string GetMethodText(IBindingMethod method)

public Exception GetCallError(IBindingMethod method, Exception ex)
{
return new BindingException($"Error calling binding method '{GetMethodText(method)}': {ex.Message}");
return new BindingException($"Error calling binding method '{GetMethodText(method)}': {ex.Message}", ex);
}

public Exception GetParameterCountError(BindingMatch match, int expectedParameterCount)
Expand Down Expand Up @@ -135,4 +135,4 @@ public Exception GetInvalidBindingRegistryError(IEnumerable<BindingError> errors
throw new BindingException("Binding error(s) found: " + Environment.NewLine + string.Join(Environment.NewLine, errors.Select(e => e.Message)));
}
}
}
}
1 change: 1 addition & 0 deletions Tests/Reqnroll.RuntimeTests/ErrorProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public void GetCallError_should_return_BindingException_containing_full_assembly
result.Should().NotBeNull();
result.Should().BeOfType<BindingException>();
result.Message.Should().Be($"Error calling binding method '{methodBindingAssemblyName}:{methodBindingTypeFullName}.{methodName}({parameter1Type}, {parameter2Type})': {expectedExceptionMessage}");
result.InnerException.Should().BeSameAs(exceptionStub.Object);
}

[Fact]
Expand Down