blob: 6a18b54c80b12d40cb8e0ae599ac4c15ed0c90cd [file] [log] [blame]
Vidyashree Rama0a6f4d42016-02-11 12:08:56 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Vidyashree Rama0a6f4d42016-02-11 12:08:56 +05303 *
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.parser.exceptions;
18
19/**
Bharat saraswald9822e92016-04-05 15:13:44 +053020 * Represents base class for exceptions in parser operations.
Vidyashree Rama0a6f4d42016-02-11 12:08:56 +053021 */
Gaurav Agrawala04483c2016-02-13 14:23:40 +053022public class ParserException extends RuntimeException {
Vidyashree Rama0a6f4d42016-02-11 12:08:56 +053023
24 private static final long serialVersionUID = 20160211L;
25 private int lineNumber;
26 private int charPositionInLine;
27 private String fileName;
Vidyashree Rama0a6f4d42016-02-11 12:08:56 +053028
29 /**
Bharat saraswald9822e92016-04-05 15:13:44 +053030 * Creates a new parser exception.
Vidyashree Rama0a6f4d42016-02-11 12:08:56 +053031 */
32 public ParserException() {
33 super();
34 }
35
36 /**
37 * Creates a new parser exception with given message.
38 *
39 * @param message the detail of exception in string
40 */
41 public ParserException(String message) {
42 super(message);
43 }
44
45 /**
46 * Creates a new parser 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 ParserException(final String message, final Throwable cause) {
52 super(message, cause);
53 }
54
55 /**
56 * Creates a new parser exception from cause.
57 *
58 * @param cause underlying cause of the error
59 */
60 public ParserException(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 /**
Vidyashree Rama0a6f4d42016-02-11 12:08:56 +053092 * 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 /**
Vidyashree Rama0a6f4d42016-02-11 12:08:56 +0530110 * 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}