blob: 755b5b4487d7b2a22e77598abb58e4e563016a45 [file] [log] [blame]
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +05301/*
2 * Copyright 2016-present Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.yangutils.linker.exceptions;
18
19/**
20 * Represents base class for exceptions in linker operations.
21 */
22public class LinkerException extends RuntimeException {
23
24 private static final long serialVersionUID = 20160211L;
25 private int lineNumber;
26 private int charPositionInLine;
27 private String fileName;
28
29 /**
30 * Creates a new linker exception.
31 */
32 public LinkerException() {
33 super();
34 }
35
36 /**
37 * Creates a new linker exception with given message.
38 *
39 * @param message the detail of exception in string
40 */
41 public LinkerException(String message) {
42 super(message);
43 }
44
45 /**
46 * Creates a new linker exception from given message and cause.
47 *
48 * @param message the detail of exception in string
49 * @param cause underlying cause of the error
50 */
51 public LinkerException(final String message, final Throwable cause) {
52 super(message, cause);
53 }
54
55 /**
56 * Creates a new linker exception from cause.
57 *
58 * @param cause underlying cause of the error
59 */
60 public LinkerException(final Throwable cause) {
61 super(cause);
62 }
63
64 /**
65 * Returns line number of the exception.
66 *
67 * @return line number of the exception
68 */
69 public int getLineNumber() {
70 return this.lineNumber;
71 }
72
73 /**
74 * Returns YANG file name of the exception.
75 *
76 * @return YANG file name of the exception
77 */
78 public String getFileName() {
79 return this.fileName;
80 }
81
82 /**
83 * Returns position of the exception.
84 *
85 * @return position of the exception
86 */
87 public int getCharPositionInLine() {
88 return this.charPositionInLine;
89 }
90
91 /**
92 * Sets line number of YANG file.
93 *
94 * @param line line number of YANG file
95 */
96 public void setLine(int line) {
97 this.lineNumber = line;
98 }
99
100 /**
101 * Sets position of exception.
102 *
103 * @param charPosition position of exception
104 */
105 public void setCharPosition(int charPosition) {
106 this.charPositionInLine = charPosition;
107 }
108
109 /**
110 * Sets file name in parser exception.
111 *
112 * @param fileName YANG file name
113 */
114 public void setFileName(String fileName) {
115 this.fileName = fileName;
116 }
117}