+ for (final SourceSpecificContext source : sources) {
+ try {
+ source.loadStatements();
+ } catch (final SourceException ex) {
+ final SourceIdentifier sourceId = Utils.createSourceIdentifier(source.getRoot());
+ throw new SomeModifiersUnresolvedException(currentPhase, sourceId, ex);
+ }
+ }
+ }
+
+ private SomeModifiersUnresolvedException addSourceExceptions(final List<SourceSpecificContext> sourcesToProgress) {
+ boolean addedCause = false;
+ SomeModifiersUnresolvedException buildFailure = null;
+ for (final SourceSpecificContext failedSource : sourcesToProgress) {
+ final Optional<SourceException> optSourceEx = failedSource.failModifiers(currentPhase);
+ if (!optSourceEx.isPresent()) {
+ continue;
+ }
+
+ final SourceException sourceEx = optSourceEx.get();
+ // Workaround for broken logging implementations which ignore
+ // suppressed exceptions
+ final Throwable cause = sourceEx.getCause() != null ? sourceEx.getCause() : sourceEx;
+ if (LOG.isDebugEnabled()) {
+ LOG.error("Failed to parse YANG from source {}", failedSource, sourceEx);
+ } else {
+ LOG.error("Failed to parse YANG from source {}: {}", failedSource, cause.getMessage());
+ }
+
+ final Throwable[] suppressed = sourceEx.getSuppressed();
+ if (suppressed.length > 0) {
+ LOG.error("{} additional errors reported:", suppressed.length);
+
+ int i = 1;
+ for (final Throwable t : suppressed) {
+ // FIXME: this should be configured in the appender, really
+ if (LOG.isDebugEnabled()) {
+ LOG.error("Error {}: {}", i, t.getMessage(), t);
+ } else {
+ LOG.error("Error {}: {}", i, t.getMessage());
+ }
+
+ i++;
+ }
+ }
+
+ if (!addedCause) {
+ addedCause = true;
+ final SourceIdentifier sourceId = Utils.createSourceIdentifier(failedSource.getRoot());
+ buildFailure = new SomeModifiersUnresolvedException(currentPhase, sourceId, sourceEx);
+ } else {
+ buildFailure.addSuppressed(sourceEx);
+ }