blob: 8da05220db6b7937c5adb2e0d691c0c6df853220 [file] [log] [blame]
Dhruv Dhodye64b93e2016-04-20 19:26:55 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Dhruv Dhodye64b93e2016-04-20 19:26:55 +05303 *
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.isis.exceptions;
17
18import com.google.common.base.MoreObjects;
19
20/**
21 * Representation of a custom exception for ISIS.
22 */
23public class IsisParseException extends Exception {
24
25 private static final long serialVersionUID = 1L;
26 private byte errorCode;
27 private byte errorSubCode;
28
29 /**
30 * Creates a new ISIS exception.
31 */
32 public IsisParseException() {
33 super();
34 }
35
36 /**
37 * Creates a new ISIS 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 IsisParseException(final String message, final Throwable cause) {
43 super(message, cause);
44 }
45
46 /**
47 * Creates a new ISIS exception for the given message.
48 *
49 * @param message the detail of exception in string
50 */
51 public IsisParseException(final String message) {
52 super(message);
53 }
54
55 /**
56 * Creates a new ISIS exception from throwable instance.
57 *
58 * @param cause underlying cause of the error
59 */
60 public IsisParseException(final Throwable cause) {
61 super(cause);
62 }
63
64 /**
65 * Creates a new ISIS exception from error code and error sub code.
66 *
67 * @param errorCode error code of ISIS message
68 * @param errorSubCode error sub code of ISIS message
69 */
70 public IsisParseException(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}