2 * Copyright (c) 2015 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/epl-v10.html
8 package org.opendaylight.yangtools.yang.parser.spi.source;
10 import com.google.common.base.Preconditions;
11 import javax.annotation.Nonnull;
15 * Thrown to indicate error in YANG model source.
18 public class SourceException extends RuntimeException {
20 private static final long serialVersionUID = 1L;
22 private final StatementSourceReference sourceRef;
24 public SourceException(@Nonnull String message,@Nonnull StatementSourceReference source) {
25 super(createMessage(message, source));
29 public SourceException(@Nonnull String message,@Nonnull StatementSourceReference source, Throwable cause) {
30 super(createMessage(message, source), cause);
34 public @Nonnull StatementSourceReference getSourceReference() {
38 private static String createMessage(@Nonnull final String message, @Nonnull final StatementSourceReference source) {
39 Preconditions.checkNotNull(message);
40 Preconditions.checkNotNull(source);
42 return String.format("%s\nStatement source at %s", message, source);