This is just my opinion, but I suspect that this is a "feature" of
Guice, and I don't know of a way to configure different behavior, but
maybe one exists.
I know in your case its the same exception causing the 3 bindings to
fail, but if there were 3 different exceptions while resolving
bindings, Guice will catch the first one and continue on, printing out
the total list of exceptions that occurred while configuring your
module. This can be useful when wiring up your application for the
first time, if it failed fast you'd find the first problem, fix it,
deploy, find the next problem, etc.
For your case, you might be able to separate your bindings using a
child injector to get the behavior you want. Something like:
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bind(Service.class).to(FaultyService.class).asEagerSingleton();
}
});
Injector childInjector = injector.createChildInjector(new
AbstractModule() {
@Override
protected void configure() {
bind(ClassA.class).asEagerSingleton();
bind(ClassB.class).asEagerSingleton();
}
});
This way if FaultyService throws an exception, the application won't
even try to create the child injector.