Can you post a stack trace?
From: first last Sent: Tuesday, December 16, 2008 1:02 PM To: [email protected] Subject: [nhusers] Re: CastleLazyInitializer does not propagate exceptions correctly 2.0 -------------------------------------------------------------------------------- From: Richard (Google) <[email protected]> To: nhusers <[email protected]> Sent: Tuesday, December 16, 2008 4:30:44 AM Subject: [nhusers] Re: CastleLazyInitializer does not propagate exceptions correctly Hi epitka, What version of NH are you using? This was sorted for V2.0 I think. Regards, Richard -------------------------------------------------- From: "epitka" <[email protected]> Sent: Monday, December 15, 2008 11:07 PM To: "nhusers" <[email protected]> Subject: [nhusers] CastleLazyInitializer does not propagate exceptions correctly > > This code in CastleLazyInitializer returns generic Exception with a > generic "Target of invoication ..." message. I am rasing > ValidationException in my code yet I cannot catch it as > ValidationException only as Exception. My exception is actually in > innerException. How am I supposed to catch custom exceptions? > > /// <summary> > /// Invoke the actual Property/Method using the Proxy or instantiate > the actual > /// object and use it when the Proxy can't handle the method. > /// </summary> > /// <param name="invocation">The <see cref="IInvocation"/> from the > generated Castle.DynamicProxy.</param> > public virtual void Intercept(IInvocation invocation) > { > try > { > if (_constructed) > { > // let the generic LazyInitializer figure out if this can be > handled > // with the proxy or if the real class needs to be initialized > invocation.ReturnValue = base.Invoke(invocation.Method, > invocation.Arguments, invocation.Proxy); > > // the base LazyInitializer could not handle it so we need to > Invoke > // the method/property against the real class > if (invocation.ReturnValue == InvokeImplementation) > { > invocation.ReturnValue = invocation.Method.Invoke > (GetImplementation(), invocation.Arguments); > return; > } > else > { > return; > } > } > else > { > // TODO: Find out equivalent to CGLIB's 'method.invokeSuper'. > return; > } > } > catch (TargetInvocationException tie) > { > // Propagate the inner exception so that the proxy throws the same > exception as > // the real object would > throw ReflectHelper.UnwrapTargetInvocationException(tie); > } > } > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
