blob: 50e2c3443a24e99843536cecec94d5d1efcb1e83 [file] [log] [blame]
Vinod Kumar S7a004de2016-02-05 16:15:09 +05301/*
2 * Copyright 2016 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 */
16package org.onosproject.yangutils.datamodel.exceptions;
17
18/**
19 * Base class for exceptions in data model operations.
20 */
21public class DataModelException extends Exception {
22
23 private static final long serialVersionUID = 201601270658L;
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053024 private int lineNumber;
25 private int charPositionInLine;
Vinod Kumar S7a004de2016-02-05 16:15:09 +053026
27 /**
28 * Constructor to create a data model exception with message.
29 *
30 * @param message the detail of exception in string
31 */
32 public DataModelException(String message) {
33 super(message);
34 }
35
36 /**
37 * Constructor to create exception from message and cause.
38 *
39 * @param message the detail of exception in string
40 * @param cause underlying cause of the error
41 */
42 public DataModelException(final String message, final Throwable cause) {
43 super(message, cause);
44 }
45
46 /**
47 * Constructor to create exception from cause.
48 *
49 * @param cause underlying cause of the error
50 */
51 public DataModelException(final Throwable cause) {
52 super(cause);
53 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053054
55 /**
56 * Returns line number of the exception.
57 *
58 * @return line number of the exception
59 */
60 public int getLineNumber() {
61 return this.lineNumber;
62 }
63
64 /**
65 * Returns position of the exception.
66 *
67 * @return position of the exception
68 */
69 public int getCharPositionInLine() {
70 return this.charPositionInLine;
71 }
72
73 /**
74 * Sets line number of YANG file.
75 *
76 * @param line line number of YANG file
77 */
78 public void setLine(int line) {
79 this.lineNumber = line;
80 }
81
82 /**
83 * Sets position of exception.
84 *
85 * @param charPosition position of exception
86 */
87 public void setCharPosition(int charPosition) {
88 this.charPositionInLine = charPosition;
89 }
Vinod Kumar S7a004de2016-02-05 16:15:09 +053090}