Remove reliance on deprecated classes in BGP components
[bgpcep.git] / bgp / parser-api / src / main / java / org / opendaylight / protocol / bgp / parser / BGPDocumentedException.java
index f3ae55702f5e339429d8b7b67b25b67419105b15..50f83be697126cbc10684dc70212d6901cff0afe 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.protocol.bgp.parser;
 
-import org.opendaylight.protocol.framework.DocumentedException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -18,7 +17,7 @@ import com.google.common.primitives.UnsignedBytes;
  * There are several errors documented in RFC4271 or in draft, that have specific meaning for the BGP. This exception is
  * used, when any of those errors occurs.
  */
-public final class BGPDocumentedException extends DocumentedException {
+public final class BGPDocumentedException extends Exception {
 
        private static final long serialVersionUID = -6212702584439430736L;
 
@@ -29,24 +28,47 @@ public final class BGPDocumentedException extends DocumentedException {
        private final byte[] data;
 
        /**
-        * Used when an error occurred that is described in rfc or draft.
+        * Used when an error occurred that is described in an RFC or a draft.
         * 
         * @param message message bound with this exception
         * @param error specific documented error
         */
        public BGPDocumentedException(final String message, final BGPError error) {
-               this(message, error, null);
+               this(message, error, null, null);
        }
 
        /**
-        * Used when an error occurred that is described in rfc or draft.
+        * Used when an error occurred that is described in an RFC or a draft.
+        * 
+        * @param message message bound with this exception
+        * @param error specific documented error
+        * @param cause cause for the error
+        */
+       public BGPDocumentedException(final String message, final BGPError error, final Exception cause) {
+               this(message, error, null, cause);
+       }
+
+       /**
+        * Used when an error occurred that is described in an RFC or a draft.
         * 
         * @param message message bound with this exception
         * @param error specific documented error
         * @param data data associated with the error
         */
        public BGPDocumentedException(final String message, final BGPError error, final byte[] data) {
-               super(message);
+               this(message, error, data, null);
+       }
+
+       /**
+        * Used when an error occurred that is described in an RFC or a draft.
+        * 
+        * @param message message bound with this exception
+        * @param error specific documented error
+        * @param data data associated with the error
+        * @param cause cause for the error
+        */
+       public BGPDocumentedException(final String message, final BGPError error, final byte[] data, final Exception cause) {
+               super(message, cause);
                this.error = error;
                this.data = data;
                logger.error("Error = " + error, this);
@@ -73,8 +95,8 @@ public final class BGPDocumentedException extends DocumentedException {
        public static BGPDocumentedException badMessageLength(final String message, final int length) {
                Preconditions.checkArgument(length >= 0 && length <= 65535);
 
-               return new BGPDocumentedException(message, BGPError.BAD_MSG_LENGTH, new byte[] {
-                               UnsignedBytes.checkedCast(length / 256), UnsignedBytes.checkedCast(length % 256) });
+               return new BGPDocumentedException(message, BGPError.BAD_MSG_LENGTH, new byte[] { UnsignedBytes.checkedCast(length / 256),
+                               UnsignedBytes.checkedCast(length % 256) });
 
        }
 }