At the moment, I am not sure how to handle the exception. But at least I would like to be able to catch the exception so to have the option of customized handling if I wish. With my example, I cannot catch it. I will dig into the things you mentioned above so if it solves my problem. You mentioned I will get a ProvisionException from Guice, from it will I be able to know the actual exception that has been thrown by AImpl's constructor?
Thanks for the help! On Jul 20, 11:25 am, Fred Faber <[email protected]> wrote: > How do you want to handle the exception is the question? You'd get a > ProvisionException from Guice in this case. > > > > > > > > On Tue, Jul 19, 2011 at 11:12 PM, laolaoyu <[email protected]> wrote: > > Modification on the above example: > > > public interface A { > > } > > > public class AImpl implements A { > > > public AImpl () throws AException {...} > > > } > > > AImpl has been bound to A. > > > On Jul 20, 11:00 am, laolaoyu <[email protected]> wrote: > > > Hi, > > > > I have a question regarding the usage of Guice constructor inject. > > > E.g. > > > > class A { > > > > public A () throws AException {...} > > > > } > > > > class B { > > > > final private A a; > > > > @Inject > > > public B (final A a) { > > > this.a = a; > > > > } > > > } > > > > As in the above case, the injected A's constructor may throw > > > exception. How should I handle this exception when using Guice? > > > > Thanks. > > > -- > > You received this message because you are subscribed to the Google Groups > > "google-guice" 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/google-guice?hl=en. -- You received this message because you are subscribed to the Google Groups "google-guice" 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/google-guice?hl=en.
