Class ModuleSetupRuntimeException

  • All Implemented Interfaces:
    Serializable

    public class ModuleSetupRuntimeException
    extends RuntimeException
    Exception to throw from a static Dependency Inject Framework's "Wiring" class.

    Also used in Lifecycle.init() and Lifecycle.destroy(), because those methods are typically called from DI's Wiring classes (typically implicitly by a DI framework, and not hand-written Wiring code).

    For example, throw this from methods in a class implementing Guice's Module interface, or from methods annotated with Dagger's @Provides in a @Module class, which "may only throw unchecked exceptions". In particular, when you have to catch checked exceptions while creating objects, wrap them into this unchecked Exception.

    When you use this Exception in a Dagger/Guice/etc. Module, you should probably write a simple test for the Module, just to verify it (alone) works at run-time (if there is a checked exception to catch, it probably initializes something that is non-trivial and could fail; so best to have a non-regression test for that Module).

    Author:
    Michael Vorburger
    See Also:
    Serialized Form
    • Constructor Detail

      • ModuleSetupRuntimeException

        public ModuleSetupRuntimeException​(Exception cause)