Imported vpnservice as a subtree
[netvirt.git] / vpnservice / bgpmanager / bgpmanager-impl / src / main / java / org / opendaylight / bgpmanager / thrift / client / BgpRouterException.java
1 /*
2  * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.bgpmanager.thrift.client;
10
11 import org.opendaylight.bgpmanager.thrift.gen.qbgpConstants;
12
13 public class BgpRouterException extends Exception {
14     public final static int BGP_ERR_INITED = 101;
15     public final static int BGP_ERR_NOT_INITED = 102;
16     public final static int BGP_ERR_IN_ITER =  103;
17
18     // the following consts are server-dictated. do not modify
19     public final static int BGP_ERR_FAILED = qbgpConstants. BGP_ERR_FAILED;
20     public final static int BGP_ERR_ACTIVE = qbgpConstants.BGP_ERR_ACTIVE;
21     public final static int BGP_ERR_INACTIVE = qbgpConstants.BGP_ERR_INACTIVE; 
22     public final static int BGP_ERR_NOT_ITER =  qbgpConstants.BGP_ERR_NOT_ITER;
23     public final static int BGP_ERR_PARAM = qbgpConstants.BGP_ERR_PARAM;
24
25     private int errcode;
26
27     public BgpRouterException(int cause) {
28         errcode = cause;
29     }
30
31     public int getErrorCode() {
32         return errcode;
33     }
34
35     public String toString() {
36       String s = "("+errcode+") ";
37
38       switch (errcode) {
39         case BGP_ERR_INITED :
40             s += "Attempt to reinitialize BgpRouter thrift client";
41             break;
42         case BGP_ERR_NOT_INITED :
43             s += "BgpRouter thrift client was not initialized";
44             break;
45         case BGP_ERR_FAILED :
46             s += "Error reported by BGP, check qbgp.log";
47             break;
48         case BGP_ERR_ACTIVE : 
49             s += "Attempt to start router instance when already active";
50             break;
51         case BGP_ERR_INACTIVE : 
52             s += "Router instance is not active";
53             break;
54         case BGP_ERR_IN_ITER :
55             s += "Attempt to start route iteration when already "+
56                  "in the middle of one";
57             break;
58         case BGP_ERR_NOT_ITER :
59             s += "Route iteration not initialized";
60             break;
61         case BGP_ERR_PARAM :
62             s += "Parameter validation or Unknown error";
63             break;
64         default : 
65             s += "Unknown error";
66             break;
67      }
68      return s;
69    }
70 }