### Question:
Context { public <T> T get(final Supplier<T> factory) { if ( factory == null ) { throw new NullPointerException("null factory"); } synchronized ( services ) { final T cached=(T)services.get(factory); if ( pending.equals(cached) ) { throw new IllegalStateException("circular dependency ["+factory+"]"); } return cached != null ? cached : context(() -> { try { services.put(factory, pending); final T acquired=((Supplier<T>)factories.getOrDefault(factory, factory)).get(); services.put(factory, acquired); return acquired; } catch ( final Throwable e ) { services.remove(factory); throw e; } }); } }  static Supplier<Path> storage(); static T service(final Supplier<T> factory); T get(final Supplier<T> factory); Context set(final Supplier<T> factory, final Supplier<T> plugin); Context clear(); Context exec(final Runnable... tasks);  }### Answer:
@Test void testHandleExceptionsInFactories() { final Context context=new Context(); final Supplier<Object> service=() -> { throw new NoSuchElementException("missing resource"); }; assertThatThrownBy(() -> context.get(service) ) .isInstanceOf(NoSuchElementException.class); }