@@ -433,35 +433,50 @@ void SerialContainerPrivate::resolveInterface(InterfaceFlags expected) {
433433 Stage& first = *children ().front ();
434434 Stage& last = *children ().back ();
435435
436- // FIRST child
437- first.pimpl ()->resolveInterface (expected & START_IF_MASK);
438- // connect first child's (start) push interface
439- setChildsPushBackwardInterface (first.pimpl ());
440- // validate that first child's and this container's start interfaces match
441- validateInterface<START_IF_MASK>(*first.pimpl (), expected);
442- // connect first child's (start) pull interface
443- if (const InterfacePtr& target = first.pimpl ()->starts ())
444- starts_.reset (new Interface (
445- [this , target](Interface::iterator it, bool updated) { this ->copyState (it, target, updated); }));
436+ InitStageException exceptions;
437+
438+ try { // FIRST child
439+ first.pimpl ()->resolveInterface (expected & START_IF_MASK);
440+ // connect first child's (start) push interface
441+ setChildsPushBackwardInterface (first.pimpl ());
442+ // validate that first child's and this container's start interfaces match
443+ validateInterface<START_IF_MASK>(*first.pimpl (), expected);
444+ // connect first child's (start) pull interface
445+ if (const InterfacePtr& target = first.pimpl ()->starts ())
446+ starts_.reset (new Interface (
447+ [this , target](Interface::iterator it, bool updated) { this ->copyState (it, target, updated); }));
448+ } catch (InitStageException& e) {
449+ exceptions.append (e);
450+ }
446451
447452 // process all children and connect them
448453 for (auto it = ++children ().begin (), previous_it = children ().begin (); it != children ().end (); ++it, ++previous_it) {
449- StagePrivate* child_impl = (**it).pimpl ();
450- StagePrivate* previous_impl = (**previous_it).pimpl ();
451- child_impl->resolveInterface (invert (previous_impl->requiredInterface ()) & START_IF_MASK);
452- connect (*previous_impl, *child_impl);
454+ try {
455+ StagePrivate* child_impl = (**it).pimpl ();
456+ StagePrivate* previous_impl = (**previous_it).pimpl ();
457+ child_impl->resolveInterface (invert (previous_impl->requiredInterface ()) & START_IF_MASK);
458+ connect (*previous_impl, *child_impl);
459+ } catch (InitStageException& e) {
460+ exceptions.append (e);
461+ }
453462 }
454463
455- // connect last child's (end) push interface
456- setChildsPushForwardInterface (last.pimpl ());
457- // validate that last child's and this container's end interfaces match
458- validateInterface<END_IF_MASK>(*last.pimpl (), expected);
459- // connect last child's (end) pull interface
460- if (const InterfacePtr& target = last.pimpl ()->ends ())
461- ends_.reset (new Interface (
462- [this , target](Interface::iterator it, bool updated) { this ->copyState (it, target, updated); }));
464+ try { // connect last child's (end) push interface
465+ setChildsPushForwardInterface (last.pimpl ());
466+ // validate that last child's and this container's end interfaces match
467+ validateInterface<END_IF_MASK>(*last.pimpl (), expected);
468+ // connect last child's (end) pull interface
469+ if (const InterfacePtr& target = last.pimpl ()->ends ())
470+ ends_.reset (new Interface (
471+ [this , target](Interface::iterator it, bool updated) { this ->copyState (it, target, updated); }));
472+ } catch (InitStageException& e) {
473+ exceptions.append (e);
474+ }
463475
464476 required_interface_ = first.pimpl ()->interfaceFlags () & START_IF_MASK | last.pimpl ()->interfaceFlags () & END_IF_MASK;
477+
478+ if (exceptions)
479+ throw exceptions;
465480}
466481
467482void SerialContainerPrivate::validateConnectivity () const {
0 commit comments