Skip to content

Preserves the stack trace when unwrapping TargetInvocationException #1443

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

Merged
merged 2 commits into from
Nov 18, 2017

Conversation

fredericDelaporte
Copy link
Member

 * Also follow up to NH-3500 which was only partially fixed.
 * Fixes nhibernate#1441
Copy link
Member Author

@fredericDelaporte fredericDelaporte left a comment

Choose a reason for hiding this comment

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

There are many other unguarded calls to MethodBase.Invoke which may cause a TargetInvocationException.

I have not change them because those other ones should yield that exception in a consistent way, meaning code catching them is expecting the TargetInvocationException.

The only unwrapping added concerns a non consistent case, where the exception could be sometimes wrapped in a TargetInvocationException or not, depending on whether the entity was proxified or not.

throw ReflectHelper.UnwrapTargetInvocationException(ex);
}
return returnValue;
return info.InvokeMethodOnTarget();
Copy link
Member Author

Choose a reason for hiding this comment

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

Unwrapping moved into InvokeMethodOnTarget, which is called two times in NHibernate code: here and a couple of lines above here.

@hazzik hazzik merged commit a4e7da2 into nhibernate:master Nov 18, 2017
@fredericDelaporte fredericDelaporte deleted the 1441 branch November 18, 2017 22:23
@fredericDelaporte fredericDelaporte added this to the 5.1 milestone Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Normalize TargetInvocationException unwrapping
2 participants