Development of NETCONF RPCs for tr-069 adapter to
[oam/tr069-adapter.git] / ves-agent / src / main / java / org / commscope / tr069adapter / vesagent / exception / VesAgentException.java
1 /*
2  * ============LICENSE_START========================================================================
3  * ONAP : tr-069-adapter
4  * =================================================================================================
5  * Copyright (C) 2020 CommScope Inc Intellectual Property.
6  * =================================================================================================
7  * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,
8  * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You
9  * may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific language governing permissions and
15  * limitations under the License.
16  * ===============LICENSE_END=======================================================================
17  */
18
19 package org.commscope.tr069adapter.vesagent.exception;
20
21 /**
22  * 
23  * @version 1.0
24  * @since May 21, 2020
25  * @author Prashant
26  */
27 public class VesAgentException extends Exception {
28   private static final long serialVersionUID = -3742697051389101875L;
29
30   private static final String ERRORMSG_PREFIX = "ves-agent";
31
32
33   private String errorCode;
34   private String message;
35
36   // index of the error occurred in the given list or in the given file
37   protected int errorIndex = -1;
38
39
40   /**
41    * Constructs a <code>VesOperationException</code> with no detail message.
42    * 
43    */
44   public VesAgentException() {
45     super();
46   }
47
48   /**
49    * Constructs a <code>VesOperationException</code> with the specified detail message.
50    * 
51    * @param s as the details message
52    */
53   public VesAgentException(String s) {
54     super(s);
55   }
56
57   public VesAgentException(String... args) {
58     super();
59     setErrorMessage(getErrorMessage());
60   }
61
62   public VesAgentException(String errorCode, String errorMsg) {
63     super();
64     this.errorCode = errorCode;
65     setErrorMessage(getErrorMessage());
66   }
67
68   public int getErrorIndex() {
69     return errorIndex;
70   }
71
72   public void setErrorIndex(int errorIndex) {
73     this.errorIndex = errorIndex;
74   }
75
76   @Override
77   public String getMessage() {
78     return message;
79   }
80
81   private String getErrorMessage() {
82     return ERRORMSG_PREFIX + ".";
83   }
84
85   private void setErrorMessage(String message) {
86     this.message = message;
87   }
88
89   public String getErrorCode() {
90     return errorCode;
91   }
92
93   public void setErrorCode(String errorCode) {
94     this.errorCode = errorCode;
95   }
96 }