*/
package org.opendaylight.protocol.bgp.parser;
-import org.opendaylight.protocol.framework.DocumentedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* 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;
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);
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) });
}
}