Large internal change:
I've replaced MissingDependencyException with ResolveFailedException, and increased the number of places where it's used. We used to have a lot of code that looked like this:
if (someBadCondition) {
addError(whatBadThingHappenedMessage);
return invalidBinding();
}
Now we do something simpler - we just throw a ResolveFailedException:
if (someBadCondition) {
throw new ResolveFailedException(whatBadThingHappenedMessage);
}
The motivation was to fix some seemingly-unrelated logic: optional bindings to providers weren't working. The problem was that the code that was calling 'addError' didn't know that it was an optional binding, and therefore not an error. This change is pretty much the only thing that could fix that problem, so I think it's worthwhile.
As an added treat, the change also fixed 2 of our 3 known test failures:
1. messaging for injecting abstract class used to be lame. Now it's good.
2. we never used to complain when leaving a dangling binding, like so:
bind(Collection.class).to(List.class);
Now we get an error when doing the list binding, and this bubbles all the way up as it should.
Since the change is big I suspect there might be some bug fallout. I'm going to run it against my standard test case (a giant application that uses Guice) to see if there's any regressions. Anything that has regressed will get its own testcase in the coming week or so...
git-svn-id: https://google-guice.googlecode.com/svn/trunk@449 d779f126-a31b-0410-b53b-1d3aecad763e
diff --git a/src/com/google/inject/ScopesCommandProcessor.java b/src/com/google/inject/ScopesCommandProcessor.java
index 583205e..a19fd05 100644
--- a/src/com/google/inject/ScopesCommandProcessor.java
+++ b/src/com/google/inject/ScopesCommandProcessor.java
@@ -18,9 +18,10 @@
import com.google.inject.commands.BindScopeCommand;
import com.google.inject.internal.Annotations;
+import com.google.inject.internal.ErrorHandler;
+import com.google.inject.internal.ErrorMessages;
import static com.google.inject.internal.Objects.nonNull;
import com.google.inject.internal.StackTraceElements;
-import com.google.inject.internal.ErrorMessages;
import java.lang.annotation.Annotation;
import java.util.Map;
@@ -35,7 +36,9 @@
private final Map<Class<? extends Annotation>, Scope> scopes;
- ScopesCommandProcessor(Map<Class<? extends Annotation>, Scope> scopes) {
+ ScopesCommandProcessor(ErrorHandler errorHandler,
+ Map<Class<? extends Annotation>, Scope> scopes) {
+ super(errorHandler);
this.scopes = scopes;
}