Vinod Kumar S | 212fcdd | 2016-02-05 16:15:09 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 0f7908b | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Vinod Kumar S | 212fcdd | 2016-02-05 16:15:09 +0530 | [diff] [blame] | 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 | package org.onosproject.yangutils.datamodel.exceptions; |
| 17 | |
| 18 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 19 | * Represents base class for exceptions in data model operations. |
Vinod Kumar S | 212fcdd | 2016-02-05 16:15:09 +0530 | [diff] [blame] | 20 | */ |
| 21 | public class DataModelException extends Exception { |
| 22 | |
| 23 | private static final long serialVersionUID = 201601270658L; |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 24 | private int lineNumber; |
| 25 | private int charPositionInLine; |
Vinod Kumar S | 212fcdd | 2016-02-05 16:15:09 +0530 | [diff] [blame] | 26 | |
| 27 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 28 | * Creates a data model exception with message. |
Vinod Kumar S | 212fcdd | 2016-02-05 16:15:09 +0530 | [diff] [blame] | 29 | * |
| 30 | * @param message the detail of exception in string |
| 31 | */ |
| 32 | public DataModelException(String message) { |
| 33 | super(message); |
| 34 | } |
| 35 | |
| 36 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 37 | * Creates exception from message and cause. |
Vinod Kumar S | 212fcdd | 2016-02-05 16:15:09 +0530 | [diff] [blame] | 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 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 47 | * Creates exception from cause. |
Vinod Kumar S | 212fcdd | 2016-02-05 16:15:09 +0530 | [diff] [blame] | 48 | * |
| 49 | * @param cause underlying cause of the error |
| 50 | */ |
| 51 | public DataModelException(final Throwable cause) { |
| 52 | super(cause); |
| 53 | } |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 54 | |
| 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 S | 212fcdd | 2016-02-05 16:15:09 +0530 | [diff] [blame] | 90 | } |