2 * Copyright (c) 2016 Cisco and/or its affiliates.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package io.fd.honeycomb.v3po.translate.v3po.util;
19 import com.google.common.annotations.Beta;
20 import com.google.common.base.Preconditions;
21 import javax.annotation.Nonnull;
24 * Thrown when Vpp jAPI method invocation failed.
27 public class VppApiInvocationException extends Exception {
28 private final String methodName;
29 private final int ctxId;
30 private final int errorCode;
33 * Constructs an VppApiInvocationFailedException with the specified api method name and error code.
35 * @param methodName method name that failed to invoke
36 * @param ctxId api request context identifier
37 * @param errorCode negative error code value associated with this failure
38 * @throws NullPointerException if apiMethodName is null
39 * @throws IllegalArgumentException if errorCode is nonnegative
41 public VppApiInvocationException(@Nonnull final String methodName, final int ctxId, final int errorCode) {
42 super(String.format("vppApi.%s failed with error code: %d (ctxId=%d) ", methodName, errorCode, ctxId));
43 this.methodName = Preconditions.checkNotNull(methodName, "apiMethodName is null!");
45 Preconditions.checkArgument(errorCode < 0);
46 this.errorCode = errorCode;
50 * Returns method name that failed to invoke.
54 public String getMethodName() {
59 * Returns api request context identifier.
61 * @return value of context identifier
63 public int getCtxId() {
68 * Returns the error code associated with this failure.
70 * @return a negative integer error code
72 public int getErrorCode() {