blob: 24e8703bbcd4f09a1328f4d9536a5da81b3b8b89 [file] [log] [blame]
Chidambar babu86b3b1a2016-02-16 17:39:52 +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 */
16package org.onosproject.ospf.exceptions;
17
18import com.google.common.base.MoreObjects;
19
20/**
21 * Representation of a custom exception for OSPF.
22 */
23public class OspfParseException extends Exception {
24
25 private static final long serialVersionUID = 1L;
26 private byte errorCode;
27 private byte errorSubCode;
28
29 /**
30 * Creates a new OSPF exception.
31 */
32 public OspfParseException() {
33 super();
34 }
35
36 /**
37 * Creates a new OSPF exception based on the given arguments.
38 *
39 * @param message the detail of exception in string
40 * @param cause underlying cause of the error
41 */
42 public OspfParseException(final String message, final Throwable cause) {
43 super(message, cause);
44 }
45
46 /**
47 * Creates a new OSPF exception for the given message.
48 *
49 * @param message the detail of exception in string
50 */
51 public OspfParseException(final String message) {
52 super(message);
53 }
54
55 /**
56 * Creates a new OSPF exception from throwable instance.
57 *
58 * @param cause underlying cause of the error
59 */
60 public OspfParseException(final Throwable cause) {
61 super(cause);
62 }
63
64 /**
65 * Creates a new OSPF exception from error code and error sub code.
66 *
67 * @param errorCode error code of OSPF message
68 * @param errorSubCode error sub code of OSPF message
69 */
70 public OspfParseException(final byte errorCode, final byte errorSubCode) {
71 super();
72 this.errorCode = errorCode;
73 this.errorSubCode = errorSubCode;
74 }
75
76 /**
77 * Returns error code for this exception.
78 *
79 * @return error code for this exception
80 */
81 public byte errorCode() {
82 return this.errorCode;
83 }
84
85 /**
86 * Returns error sub code for this exception.
87 *
88 * @return error sub code for this exception
89 */
90 public byte errorSubCode() {
91 return this.errorSubCode;
92 }
93
94 @Override
95 public String toString() {
96 return MoreObjects.toStringHelper(getClass())
97 .omitNullValues()
98 .add("errorCode", errorCode)
99 .add("errorSubCode", errorSubCode)
100 .toString();
101 }
102}