131131import org .slf4j .LoggerFactory ;
132132
133133import com .google .common .base .Joiner ;
134+ import com .google .common .base .Throwables ;
134135import com .google .common .collect .ImmutableList ;
135136import com .google .common .collect .ImmutableMap ;
136137import com .google .common .collect .ImmutableSet ;
@@ -524,7 +525,7 @@ default Config config() {
524525 * @param conf The current config object. Not null.
525526 * @param binder A guice binder. Not null.
526527 */
527- void configure (Env env , Config conf , Binder binder );
528+ void configure (Env env , Config conf , Binder binder ) throws Throwable ;
528529
529530 }
530531
@@ -2427,7 +2428,7 @@ private static List<Object> processEnvDep(final Set<Object> src, final Env env)
24272428 }
24282429
24292430 private Injector bootstrap (final Config args ,
2430- final Consumer <List <Route .Definition >> rcallback ) throws Exception {
2431+ final Consumer <List <Route .Definition >> rcallback ) throws Throwable {
24312432 Config appconf = ConfigFactory .parseResources ("application.conf" );
24322433 Config initconf = srcconf == null ? appconf : srcconf .withFallback (appconf );
24332434 List <Config > modconf = modconf (this .bag );
@@ -2575,18 +2576,21 @@ private Injector bootstrap(final Config args,
25752576
25762577 /** modules, routes, parsers, renderers and websockets */
25772578 Set <Object > routeClasses = new HashSet <>();
2578- bag .forEach (it -> bindService (
2579- this .bag ,
2580- finalConfig ,
2581- finalEnv ,
2582- rm ,
2583- binder ,
2584- definitions ,
2585- sockets ,
2586- ehandlers ,
2587- parsers ,
2588- renderers ,
2589- routeClasses ).accept (it ));
2579+ for (Object it : bag ) {
2580+ Try .run (() -> bindService (
2581+ this .bag ,
2582+ finalConfig ,
2583+ finalEnv ,
2584+ rm ,
2585+ binder ,
2586+ definitions ,
2587+ sockets ,
2588+ ehandlers ,
2589+ parsers ,
2590+ renderers ,
2591+ routeClasses ).accept (it ))
2592+ .getOrElseThrow (Throwables ::propagate );
2593+ }
25902594
25912595 parsers .addBinding ().toInstance (new DateParser (dateFormat ));
25922596 parsers .addBinding ().toInstance (new LocalDateParser (dateTimeFormatter ));
@@ -2711,7 +2715,7 @@ private static Provider<Session.Definition> session(final Config $session,
27112715 };
27122716 }
27132717
2714- private static Consumer <? super Object > bindService (final Set <Object > src ,
2718+ private static CheckedConsumer <? super Object > bindService (final Set <Object > src ,
27152719 final Config conf ,
27162720 final Env env ,
27172721 final RouteMetadata rm ,
@@ -2729,18 +2733,20 @@ private static Consumer<? super Object> bindService(final Set<Object> src,
27292733 int to = src .size ();
27302734 // collect any route a module might add
27312735 if (to > from ) {
2732- normalize (new ArrayList <>(src ).subList (from , to ), env , rm , null )
2733- .forEach (e -> bindService (src ,
2734- conf ,
2735- env ,
2736- rm ,
2737- binder ,
2738- definitions ,
2739- sockets ,
2740- ehandlers ,
2741- parsers ,
2742- renderers ,
2743- routeClasses ).accept (e ));
2736+ List <Object > elements = normalize (new ArrayList <>(src ).subList (from , to ), env , rm , null );
2737+ for (Object e : elements ) {
2738+ bindService (src ,
2739+ conf ,
2740+ env ,
2741+ rm ,
2742+ binder ,
2743+ definitions ,
2744+ sockets ,
2745+ ehandlers ,
2746+ parsers ,
2747+ renderers ,
2748+ routeClasses ).accept (e );
2749+ }
27442750 }
27452751 } else if (it instanceof Route .Definition ) {
27462752 Route .Definition rdef = (Definition ) it ;
@@ -3025,14 +3031,11 @@ private Config defaultConfig(final Config config) {
30253031 * @param env Application env.
30263032 * @param config The configuration object.
30273033 * @param binder A Guice binder.
3034+ * @throws Throwable If module bootstrap fails.
30283035 */
30293036 private static void install (final Jooby .Module module , final Env env , final Config config ,
3030- final Binder binder ) {
3031- try {
3032- module .configure (env , config , binder );
3033- } catch (Exception ex ) {
3034- throw new IllegalStateException ("Error found on module: " + module .getClass ().getName (), ex );
3035- }
3037+ final Binder binder ) throws Throwable {
3038+ module .configure (env , config , binder );
30363039 }
30373040
30383041 /**
0 commit comments