2 * Copyright (c) 2013 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.data.impl.leafref;
10 import static java.util.Objects.requireNonNull;
12 public class LeafRefYangSyntaxErrorException extends Exception {
13 private static final long serialVersionUID = 1L;
14 private final String module;
15 private final int line;
16 private final int charPositionInLine;
18 public LeafRefYangSyntaxErrorException(final String module, final int line, final int charPositionInLine,
19 final String message) {
20 this(module, line, charPositionInLine, message, null);
23 public LeafRefYangSyntaxErrorException(final String module, final int line, final int charPositionInLine,
24 final String message, final Throwable cause) {
25 super(requireNonNull(message), cause);
28 this.charPositionInLine = charPositionInLine;
31 public String getModule() {
35 public int getLine() {
39 public int getCharPositionInLine() {
40 return charPositionInLine;
43 public String getFormattedMessage() {
44 final StringBuilder sb = new StringBuilder(getMessage());
46 sb.append(" in module ");
50 sb.append(" on line ");
52 if (charPositionInLine != 0) {
53 sb.append(" character ");
54 sb.append(charPositionInLine);
61 public String toString() {
62 return this.getClass().getName() + ": " + getFormattedMessage();