blob: d08903202c88d3700964d3fe4ab75be67c14b045 [file] [log] [blame]
Satish Ke107e662015-09-21 19:00:17 +05301/*
2 * Copyright 2015 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.bgpio.exceptions;
18
19import org.jboss.netty.buffer.ChannelBuffer;
20
21/**
22 * Custom Exception for BGP IO.
23 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053024public class BgpParseException extends Exception {
Satish Ke107e662015-09-21 19:00:17 +053025
26 private static final long serialVersionUID = 1L;
27 private byte errorCode;
28 private byte errorSubCode;
29 private ChannelBuffer data;
30
31 /**
32 * Default constructor to create a new exception.
33 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053034 public BgpParseException() {
Satish Ke107e662015-09-21 19:00:17 +053035 super();
36 }
37
38 /**
39 * Constructor to create exception from message and cause.
40 *
41 * @param message the detail of exception in string
42 * @param cause underlying cause of the error
43 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053044 public BgpParseException(final String message, final Throwable cause) {
Satish Ke107e662015-09-21 19:00:17 +053045 super(message, cause);
46 }
47
48 /**
49 * Constructor to create exception from message.
50 *
51 * @param message the detail of exception in string
52 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053053 public BgpParseException(final String message) {
Satish Ke107e662015-09-21 19:00:17 +053054 super(message);
55 }
56
57 /**
58 * Constructor to create exception from cause.
59 *
60 * @param cause underlying cause of the error
61 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053062 public BgpParseException(final Throwable cause) {
Satish Ke107e662015-09-21 19:00:17 +053063 super(cause);
64 }
65
66 /**
67 * Constructor to create exception from error code and error subcode.
68 *
69 * @param errorCode error code of BGP message
70 * @param errorSubCode error subcode of BGP message
71 * @param data error data of BGP message
72 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053073 public BgpParseException(final byte errorCode, final byte errorSubCode, final ChannelBuffer data) {
Satish Ke107e662015-09-21 19:00:17 +053074 super();
75 this.errorCode = errorCode;
76 this.errorSubCode = errorSubCode;
77 this.data = data;
78 }
79
80 /**
81 * Returns errorcode for this exception.
82 *
83 * @return errorcode for this exception
84 */
85 public byte getErrorCode() {
86 return this.errorCode;
87 }
88
89 /**
90 * Returns error Subcode for this exception.
91 *
92 * @return error Subcode for this exception
93 */
94 public byte getErrorSubCode() {
95 return this.errorSubCode;
96 }
97
98 /**
99 * Returns error data for this exception.
100 *
101 * @return error data for this exception
102 */
103 public ChannelBuffer getData() {
104 return this.data;
105 }
106}