Serialization fixup round one. I still have lots of work before everything serializes properly...
Also fixing the InternalFactory class so it wraps exceptions properly. This is a change in behaviour from 1.0 - now custom exceptions always get wrapped. This makes it so the only exception users need to catch is a ProvisionException.
git-svn-id: https://google-guice.googlecode.com/svn/trunk@488 d779f126-a31b-0410-b53b-1d3aecad763e
diff --git a/src/com/google/inject/InternalFactoryToProviderAdapter.java b/src/com/google/inject/InternalFactoryToProviderAdapter.java
index 59ae441..6b5fa95 100644
--- a/src/com/google/inject/InternalFactoryToProviderAdapter.java
+++ b/src/com/google/inject/InternalFactoryToProviderAdapter.java
@@ -16,6 +16,7 @@
package com.google.inject;
+import com.google.inject.internal.ErrorMessages;
import com.google.inject.internal.Objects;
import com.google.inject.spi.SourceProviders;
@@ -39,8 +40,13 @@
public T get(InternalContext context, InjectionPoint<?> injectionPoint) {
context.ensureMemberInjected(provider);
- T provided = provider.get();
- return injectionPoint.checkForNull(provided, source);
+ try {
+ return injectionPoint.checkForNull(provider.get(), source);
+ } catch(ProvisionException e) {
+ throw e;
+ } catch(RuntimeException e) {
+ throw new ProvisionException(e, ErrorMessages.ERROR_IN_PROVIDER);
+ }
}
public String toString() {