Open GoogleCodeExporter opened 9 years ago
I've changed ProvisionException to be public and to avoid nesting itself.
I still need to update the Javadocs for Provider, and find a way to reduce the
attempted duplication of
contexts. Currently its possible for a single injection to attempt to rewrapped
multiple times.
Although the format is flexible, the new exception messages look like this when
injecting A(B(C(D))):
com.google.inject.ProvisionException: Error injecting constructor
while locating com.google.inject.ProvisionExceptionTest$D
for parameter 0 at com.google.inject.ProvisionExceptionTest$C.setD(ProvisionExceptionTest.java:73)
while locating com.google.inject.ProvisionExceptionTest$C
for field at com.google.inject.ProvisionExceptionTest$B.c(ProvisionExceptionTest.java:68)
while locating com.google.inject.ProvisionExceptionTest$B
for parameter 0 at com.google.inject.ProvisionExceptionTest$A.<init>(ProvisionExceptionTest.java:66)
at com.google.inject.ConstructorInjector.construct(ConstructorInjector.java:162)
at com.google.inject.InjectorImpl$ImplicitBinding.get(InjectorImpl.java:1040)
at com.google.inject.InjectorImpl$SingleParameterInjector.inject(InjectorImpl.java:661)
at com.google.inject.InjectorImpl.getParameters(InjectorImpl.java:692)
at com.google.inject.InjectorImpl$SingleMethodInjector.inject(InjectorImpl.java:577)
at com.google.inject.ConstructorInjector.construct(ConstructorInjector.java:155)
at com.google.inject.InjectorImpl$ImplicitBinding.get(InjectorImpl.java:1040)
at com.google.inject.InjectorImpl$SingleFieldInjector.inject(InjectorImpl.java:471)
at com.google.inject.ConstructorInjector.construct(ConstructorInjector.java:155)
at com.google.inject.InjectorImpl$ImplicitBinding.get(InjectorImpl.java:1040)
at com.google.inject.InjectorImpl$SingleParameterInjector.inject(InjectorImpl.java:661)
at com.google.inject.InjectorImpl.getParameters(InjectorImpl.java:692)
at com.google.inject.ConstructorInjector.construct(ConstructorInjector.java:140)
at com.google.inject.InjectorImpl$ImplicitBinding.get(InjectorImpl.java:1040)
at com.google.inject.InjectorImpl$9$1.call(InjectorImpl.java:739)
at com.google.inject.InjectorImpl.callInContext(InjectorImpl.java:778)
at com.google.inject.InjectorImpl$9.get(InjectorImpl.java:732)
at com.google.inject.InjectorImpl.getInstance(InjectorImpl.java:759)
at com.google.inject.ProvisionExceptionTest.testExceptionsCollapsed(ProvisionExceptionTest.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at com.intellij.rt.execution.junit.IdeaTestRunner.doRun(IdeaTestRunner.java:69)
at junit.textui.TestRunner.doRun(TestRunner.java:109)
at com.intellij.rt.execution.junit.IdeaTestRunner.startRunnerWithArgs(IdeaTestRunner.java:24)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:118)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
Caused by: java.lang.UnsupportedOperationException
at com.google.inject.ProvisionExceptionTest$D.<init>(ProvisionExceptionTest.java:77)
at
com.google.inject.ProvisionExceptionTest$D$$FastClassByGuice$$5d1f9381.newInstan
ce(<generated>)
at net.sf.cglib.reflect.FastConstructor.newInstance(FastConstructor.java:40)
at
com.google.inject.DefaultConstructionProxyFactory$2.newInstance(DefaultConstruct
ionProxyFactory.java:67)
at com.google.inject.ConstructorInjector.construct(ConstructorInjector.java:142)
... 34 more
Original comment by limpbizkit
on 25 Aug 2007 at 8:15
Note that I am unwrapping InvocationTargetExceptions. So if the user's
Constructor looks like this:
public MyClass() {
throw new MyException();
}
then the cause of the thrown ProvisionException will be a MyException and not
an InvocationTargetException.
This hides the user from reflection in the current implementation, and it makes
the catch() block more
understandable.
Original comment by limpbizkit
on 25 Aug 2007 at 8:19
aren't issue 23 and issue 111 related?
Original comment by robbie.v...@gmail.com
on 25 Aug 2007 at 10:47
Original comment by limpbizkit
on 8 Jun 2008 at 11:32
Original comment by limpbizkit
on 2 Nov 2008 at 5:22
Original issue reported on code.google.com by
limpbizkit
on 25 Aug 2007 at 8:12