2 * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.infrautils.inject;
11 * Exception to throw from a static Dependency Inject Framework's "Wiring" class.
13 * <p>Also used in {@link Lifecycle#init()} and {@link Lifecycle#destroy()}, because
14 * those methods are typically called from DI's Wiring classes (typically implicitly
15 * by a DI framework, and not hand-written Wiring code).
17 * <p>For example, throw this from methods in a class implementing Guice's Module
18 * interface, or from methods annotated with Dagger's @Provides in a @Module
19 * class, which <i>"may only throw unchecked exceptions"</i>. In particular, when you
20 * have to catch checked exceptions while creating objects, wrap them into this
21 * unchecked Exception.
23 * <p>When you use this Exception in a Dagger/Guice/etc. Module, you should
24 * probably write a simple test for the Module, just to verify it (alone) works
25 * at run-time (if there is a checked exception to catch, it probably
26 * initializes something that is non-trivial and could fail; so best to have a
27 * non-regression test for that Module).
29 * @author Michael Vorburger
31 public class ModuleSetupRuntimeException extends RuntimeException {
33 private static final long serialVersionUID = -1795982967617796415L;
35 public ModuleSetupRuntimeException(Exception cause) {