1 /*
2 * Copyright (c) 2021 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 #include "appexecfwk_errors.h"
17 #include "form_errors.h"
18
19 namespace OHOS {
20 namespace AppExecFwk {
FormErrors()21 FormErrors::FormErrors()
22 {
23 InitErrorMessageMap();
24 }
~FormErrors()25 FormErrors::~FormErrors()
26 {
27 }
28
29 /**
30 * @brief Get the error message content.
31 *
32 * @param errCode Error code.
33 * @return Message content.
34 */
GetErrorMessage(int errCode)35 std::string FormErrors::GetErrorMessage(int errCode)
36 {
37 if(errorMessageMap_.find(errCode) != errorMessageMap_.end()) {
38 return errorMessageMap_[errCode];
39 }
40 else {
41 return errorMessageMap_[ERR_APPEXECFWK_FORM_COMMON_CODE];
42 }
43 }
44
45 /**
46 * @brief Init error message map object.
47 *
48 */
InitErrorMessageMap()49 void FormErrors::InitErrorMessageMap()
50 {
51 errorMessageMap_ = { // error + message
52 {
53 ERR_APPEXECFWK_FORM_COMMON_CODE, "some internal server error occurs.",
54 },
55 {
56 ERR_APPEXECFWK_FORM_PERMISSION_DENY,
57 "check permission deny, need to request ohos.permission.REQUIRE_FORM.",
58 },
59 {
60 ERR_APPEXECFWK_FORM_GET_INFO_FAILED, "can't get form info by the formName.",
61 },
62 {
63 ERR_APPEXECFWK_FORM_GET_BUNDLE_FAILED, "the requested bundle name does not exist.",
64 },
65 {
66 ERR_APPEXECFWK_FORM_INVALID_PARAM, "invalid params received on operating form.",
67 },
68 {
69 ERR_APPEXECFWK_FORM_CFG_NOT_MATCH_ID, "the form id and form config are not matched.",
70 },
71 {
72 ERR_APPEXECFWK_FORM_NOT_EXIST_ID, "the requested form id is not existed on fms.",
73 },
74 {
75 ERR_APPEXECFWK_FORM_BIND_PROVIDER_FAILED, "fms bind provider failed.",
76 },
77 {
78 ERR_APPEXECFWK_FORM_MAX_SYSTEM_FORMS, "exceed max forms in system, current limit is 512.",
79 },
80 {
81 ERR_APPEXECFWK_FORM_EXCEED_INSTANCES_PER_FORM, "exceed max instances per form, limit is 32.",
82 },
83 {
84 ERR_APPEXECFWK_FORM_OPERATION_NOT_SELF,
85 "the form to be operated is not self-owned or has been deleted already.",
86 },
87 {
88 ERR_APPEXECFWK_FORM_PROVIDER_DEL_FAIL, "fms notify provider to delete failed.",
89 },
90 {
91 ERR_APPEXECFWK_FORM_MAX_FORMS_PER_CLIENT, "exceed max forms per client, limit is 256.",
92 },
93 {
94 ERR_APPEXECFWK_FORM_MAX_SYSTEM_TEMP_FORMS, "exceed max temp forms in system, limit is 256.",
95 },
96 {
97 ERR_APPEXECFWK_FORM_NO_SUCH_MODULE, "the module not exist in the bundle.",
98 },
99 {
100 ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY, "the ability not exist in the module.",
101 },
102 {
103 ERR_APPEXECFWK_FORM_NO_SUCH_DIMENSION, "the dimension not exist in the form.",
104 },
105 {
106 ERR_APPEXECFWK_FORM_FA_NOT_INSTALLED, "the ability not installed,need install first.",
107 },
108 {
109 ERR_APPEXECFWK_FORM_MAX_REQUEST, "too many request,try again later.",
110 },
111 {
112 ERR_APPEXECFWK_FORM_MAX_REFRESH, "already refresh 50 times.",
113 },
114 {
115 ERR_APPEXECFWK_FORM_GET_BMS_FAILED, "get bms rpc failed.",
116 },
117 {
118 ERR_APPEXECFWK_FORM_GET_FMS_FAILED, "get fms rpc failed.",
119 },
120 {
121 ERR_APPEXECFWK_FORM_SEND_FMS_MSG, "send request to fms failed.",
122 },
123 {
124 ERR_APPEXECFWK_FORM_FORM_DUPLICATE_ADDED, "form do not support acquire same id twice.",
125 },
126 {
127 ERR_APPEXECFWK_FORM_IN_RECOVER, "form is in recover status, can't do action on form.",
128 },
129 {
130 ERR_APPEXECFWK_FORM_GET_SYSMGR_FAILED, "get system manager failed.",
131 },
132 {
133 ERR_APPEXECFWK_PARCEL_ERROR, "read parcelable info failed.",
134 },
135 };
136 }
137
138 } // namespace AppExecFwk
139 } // namespace OHOS