2 * Copyright (c) 2014 Cisco Systems, 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/eplv10.html
8 package org.opendaylight.yangtools.yang.model.repo.api;
10 import com.google.common.base.Objects;
11 import com.google.common.base.Objects.ToStringHelper;
12 import com.google.common.base.Preconditions;
13 import com.google.common.collect.ImmutableMap;
17 import javax.annotation.Nonnull;
20 * Exception thrown when a Schema Source fails to resolve.
22 public class SchemaResolutionException extends Exception {
23 private static final long serialVersionUID = 1L;
24 private final Map<SourceIdentifier, Throwable> unresolvedSources;
26 public SchemaResolutionException(final @Nonnull String message) {
27 this(message, (Throwable)null);
30 public SchemaResolutionException(final @Nonnull String message, final Throwable cause) {
31 this(message, cause, ImmutableMap.<SourceIdentifier, Exception>of());
34 public SchemaResolutionException(final @Nonnull String message, final @Nonnull Map<SourceIdentifier, ? extends Throwable> unresolvedSources) {
35 super(Preconditions.checkNotNull(message));
36 this.unresolvedSources = ImmutableMap.copyOf(unresolvedSources);
39 public SchemaResolutionException(final @Nonnull String message, final Throwable cause, @Nonnull final Map<SourceIdentifier, ? extends Throwable> unresolvedSources) {
40 super(message, cause);
41 this.unresolvedSources = ImmutableMap.copyOf(unresolvedSources);
45 * Return the list of sources which failed to resolve along with reasons
46 * why they were not resolved.
48 * @return Source/reason map.
50 public final Map<SourceIdentifier, Throwable> getUnresolvedSources() {
51 return unresolvedSources;
55 public final String toString() {
56 return addToStringAttributes(Objects.toStringHelper(this).add("unresolvedSources", unresolvedSources)).toString();
59 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
60 return toStringHelper;