Skip to content

Commit 04e99bc

Browse files
committed
DefaultLazyInitializer - remove code duplication
1 parent a1cce04 commit 04e99bc

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/NHibernate/Proxy/DefaultLazyInitializer.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@
44
using NHibernate.Proxy.DynamicProxy;
55
using NHibernate.Proxy.Poco;
66
using NHibernate.Type;
7+
using NHibernate.Util;
78

89
namespace NHibernate.Proxy
910
{
1011
[Serializable]
1112
public class DefaultLazyInitializer : BasicLazyInitializer, DynamicProxy.IInterceptor
1213
{
13-
[NonSerialized]
14-
private static readonly MethodInfo exceptionInternalPreserveStackTrace =
15-
typeof (Exception).GetMethod("InternalPreserveStackTrace", BindingFlags.Instance | BindingFlags.NonPublic);
16-
1714
public DefaultLazyInitializer(string entityName, System.Type persistentClass, object id, MethodInfo getIdentifierMethod,
1815
MethodInfo setIdentifierMethod, IAbstractComponentType componentIdType,
1916
ISessionImplementor session)
@@ -38,8 +35,7 @@ public object Intercept(InvocationInfo info)
3835
}
3936
catch (TargetInvocationException ex)
4037
{
41-
exceptionInternalPreserveStackTrace.Invoke(ex.InnerException, new Object[] {});
42-
throw ex.InnerException;
38+
throw ReflectHelper.UnwrapTargetInvocationException(ex);
4339
}
4440

4541
return returnValue;

0 commit comments

Comments
 (0)