• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2024 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 UDMF_ERROR_CODE_H
17 #define UDMF_ERROR_CODE_H
18 
19 #include <cstdint>
20 #include <errors.h>
21 #include <map>
22 #include <string>
23 #include <unordered_map>
24 
25 namespace OHOS {
26 namespace UDMF {
27 enum UdmfModule {
28     UDMF_MODULE_SERVICE_ID = 0x07,
29 };
30 
31 // UDMF error offset, used only in this file.
32 constexpr ErrCode UDMF_ERR_OFFSET = ErrCodeOffset(SUBSYS_DISTRIBUTEDDATAMNG, UDMF_MODULE_SERVICE_ID);
33 
34 enum Status : int32_t {
35     E_OK = ERR_OK,
36     E_ERROR,
37     E_WRITE_PARCEL_ERROR = UDMF_ERR_OFFSET,
38     E_READ_PARCEL_ERROR,
39     E_IPC,
40     E_NO_PERMISSION,
41     E_INVALID_PARAMETERS,
42     E_DB_ERROR,
43     E_FS_ERROR,
44     E_NOT_FOUND,
45     E_SETTINGS_EXISTED,
46     E_NO_SYSTEM_PERMISSION,
47     E_SYNC_FAILED,
48     E_COPY_FILE_FAILED,
49     E_IDEMPOTENT_ERROR,
50     E_COPY_CANCELED,
51     E_BUTT,
52 };
53 
54 static const std::unordered_map<int32_t, std::string> ERROR_MAP {
55     { Status::E_OK, "E_OK" },
56     { Status::E_ERROR, "E_ERROR" },
57     { Status::E_WRITE_PARCEL_ERROR, "E_WRITE_PARCEL_ERROR" },
58     { Status::E_READ_PARCEL_ERROR, "E_READ_PARCEL_ERROR" },
59     { Status::E_IPC, "E_IPC" },
60     { Status::E_NO_PERMISSION, "E_NO_PERMISSION" },
61     { Status::E_INVALID_PARAMETERS, "E_INVALID_PARAMETERS" },
62     { Status::E_DB_ERROR, "E_DB_ERROR" },
63     { Status::E_FS_ERROR, "E_FS_ERROR" },
64     { Status::E_NOT_FOUND, "E_NOT_FOUND" },
65     { Status::E_SETTINGS_EXISTED, "E_SETTINGS_EXISTED" },
66     { Status::E_NO_SYSTEM_PERMISSION, "E_NO_SYSTEM_PERMISSION" }
67 };
68 } // namespace UDMF
69 } // namespace OHOS
70 #endif // UDMF_ERROR_CODE_H