1 /*
2  * Copyright (C) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef JS_ERROR_CODE_H
17 #define JS_ERROR_CODE_H
18 
19 #include <string>
20 
21 #include "telephony_errors.h"
22 
23 namespace OHOS {
24 namespace Telephony {
25 /**
26  * @brief Indicates the error code for JS.
27  */
28 enum JsErrorCode {
29     /**
30      * Permission denied.
31      */
32     JS_ERROR_TELEPHONY_PERMISSION_DENIED = 201,
33 
34     /**
35      * Non-system applications use system APIs.
36      */
37     JS_ERROR_ILLEGAL_USE_OF_SYSTEM_API = 202,
38 
39     /**
40      * Invalid parameter value. The types of parameters should match, or the number of parameters must match.
41      */
42     JS_ERROR_TELEPHONY_INVALID_INPUT_PARAMETER = 401,
43 
44     /**
45      * The device does not support this API. It is usually used to support a small number of APIs when the device has
46      * supported the SysCap.
47      */
48     JS_ERROR_DEVICE_NOT_SUPPORT_THIS_API = 801,
49 
50     /**
51      * Success.
52      */
53     JS_ERROR_TELEPHONY_SUCCESS = 8300000,
54 
55     /**
56      * The input parameter value is out of range.
57      */
58     JS_ERROR_TELEPHONY_ARGUMENT_ERROR,
59 
60     /**
61      * Operation failed. Cannot connect to service.
62      */
63     JS_ERROR_TELEPHONY_SERVICE_ERROR,
64 
65     /**
66      * System internal error.
67      */
68     JS_ERROR_TELEPHONY_SYSTEM_ERROR,
69 
70     /**
71      * Do not have sim card.
72      */
73     JS_ERROR_TELEPHONY_NO_SIM_CARD,
74 
75     /**
76      * Airplane mode is on.
77      */
78     JS_ERROR_TELEPHONY_AIRPLANE_MODE_ON,
79 
80     /**
81      * Network not in service.
82      */
83     JS_ERROR_TELEPHONY_NETWORK_NOT_IN_SERVICE,
84 
85     /**
86      * Conference call is exceed limit.
87      */
88     JS_ERROR_TELEPHONY_CONFERENCE_EXCEED_LIMIT,
89 
90     /**
91      * call count exceeds limit.
92      */
93     JS_ERROR_TELEPHONY_CALL_COUNTS_EXCEED_LIMIT,
94 
95     /**
96      * Conference call is not active.
97      */
98     JS_ERROR_TELEPHONY_CONFERENCE_CALL_NOT_ACTIVE,
99 
100     /**
101      * Dial is busy.
102      */
103     JS_ERROR_TELEPHONY_DIAL_IS_BUSY,
104 
105     /**
106      * Unknown error code.
107      */
108     JS_ERROR_TELEPHONY_UNKNOW_ERROR = 8300999,
109 
110     /**
111      * Sim module base error code.
112      */
113     JS_ERROR_SIM_BASE_ERROR = 8301000,
114 
115     /**
116      * SIM card is not activated.
117      */
118     JS_ERROR_SIM_CARD_IS_NOT_ACTIVE,
119 
120     /**
121      * SIM card operation error.
122      */
123     JS_ERROR_SIM_CARD_OPERATION_ERROR,
124 
125     /**
126      * Operator config error.
127      */
128     JS_ERROR_OPERATOR_CONFIG_ERROR,
129 
130     /**
131      * Network search module base error code.
132      */
133     JS_ERROR_NETWORK_SEARCH_BASE_ERROR = 8302000,
134 
135     /**
136      * Call manager module base error code.
137      */
138     JS_ERROR_CALL_MANAGER_BASE_ERROR = 8401000,
139 
140     /**
141      * UT is not connected.
142      */
143     JS_ERROR_CALL_UT_NO_CONNECTION,
144 
145     /**
146      * Cellular call module cs base error code.
147      */
148     JS_ERROR_CELLULAR_CALL_CS_BASE_ERROR = 8501000,
149 
150     /**
151      * Cellular call module ims base error code.
152      */
153     JS_ERROR_CELLULAR_CALL_IMS_BASE_ERROR = 8502000,
154 
155     /**
156      * Cellular data module base error code.
157      */
158     JS_ERROR_CELLULAR_DATA_BASE_ERROR = 8601000,
159 
160     /**
161      * Sms mms module base error code.
162      */
163     JS_ERROR_SMS_MMS_BASE_ERROR = 8701000,
164 
165     /**
166      * State registry module base error code.
167      */
168     JS_ERROR_STATE_REGISTRY_BASE_ERROR = 8801000,
169 
170     /**
171      * VCard module base error code.
172      */
173     JS_ERROR_VCARD_BASE_ERROR = 8901000,
174 
175     /**
176      * VCard file invalid.
177      */
178     JS_ERROR_VCARD_FILE_INVALID,
179 };
180 
181 struct JsError {
182     JsErrorCode errorCode = JsErrorCode::JS_ERROR_TELEPHONY_UNKNOW_ERROR;
183     std::string errorMessage = "";
184 };
185 } // namespace Telephony
186 } // namespace OHOS
187 #endif // JS_ERROR_CODE_H
188