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 #ifndef PREFERENCES_ERRNO_H 17 #define PREFERENCES_ERRNO_H 18 19 #include <errno.h> 20 21 namespace OHOS { 22 namespace NativePreferences { 23 24 constexpr int SUBSYS_DISTRIBUTEDDATAMNG = 13; 25 constexpr int SUBSYSTEM_BIT_NUM = 21; 26 constexpr int MODULE_BIT_NUM = 16; 27 constexpr int MODULE_PREFERENCES = 6; 28 constexpr int DISTRIBUTEDDATAMGR_PREFERENCES_ERR_OFFSET = (SUBSYS_DISTRIBUTEDDATAMNG << SUBSYSTEM_BIT_NUM) | 29 (MODULE_PREFERENCES << MODULE_BIT_NUM); 30 31 /** 32 * @brief The error code in the correct case. 33 */ 34 constexpr int E_OK = 0; 35 36 /** 37 * @brief The base code of the exception error code. 38 */ 39 constexpr int E_BASE = DISTRIBUTEDDATAMGR_PREFERENCES_ERR_OFFSET; 40 41 /** 42 * @brief The error when the capability not supported. 43 */ 44 constexpr int E_NOT_SUPPORTED = (E_BASE + 801); 45 46 /** 47 * @brief The error code for common exceptions. 48 */ 49 constexpr int E_ERROR = E_BASE; 50 51 /** 52 * @brief The error code for resource has been stopped, killed or destroyed. 53 */ 54 constexpr int E_STALE = (E_BASE + 1); // Resource has been stopped, killed or destroyed. 55 56 /** 57 * @brief The error code for the input args is invalid. 58 */ 59 constexpr int E_INVALID_ARGS = (E_BASE + 2); // the input args is invalid. 60 61 /** 62 * @brief The error code for out of memory. 63 */ 64 constexpr int E_OUT_OF_MEMORY = (E_BASE + 3); // out of memory 65 66 /** 67 * @brief The error code for operation is not permitted. 68 */ 69 constexpr int E_NOT_PERMIT = (E_BASE + 4); // operation is not permitted 70 71 /** 72 * @brief The error code for the key is empty. 73 */ 74 constexpr int E_KEY_EMPTY = (E_BASE + 5); 75 76 /** 77 * @brief The error code for the key string length exceed the max length (1024). 78 */ 79 constexpr int E_KEY_EXCEED_MAX_LENGTH = (E_BASE + 6); 80 81 /** 82 * @brief The error code for the former Preferences object pointer is held by another thread and may 83 * not be able to be deleted. 84 */ 85 constexpr int E_PTR_EXIST_ANOTHER_HOLDER = (E_BASE + 7); 86 87 /** 88 * @brief The error code for the file path is relative path. 89 */ 90 constexpr int E_RELATIVE_PATH = (E_BASE + 8); 91 92 /** 93 * @brief The error code for the file path is empty. 94 */ 95 constexpr int E_EMPTY_FILE_PATH = (E_BASE + 9); 96 97 /** 98 * @brief The error code when deleting a file fails. 99 */ 100 constexpr int E_DELETE_FILE_FAIL = (E_BASE + 10); 101 102 /** 103 * @brief The error code for the file name is empty. 104 */ 105 constexpr int E_EMPTY_FILE_NAME = (E_BASE + 11); 106 107 /** 108 * @brief The error code for the file path is invalid. 109 */ 110 constexpr int E_INVALID_FILE_PATH = (E_BASE + 12); 111 112 /** 113 * @brief The error code for the file path exceeds the max length. 114 */ 115 constexpr int E_PATH_EXCEED_MAX_LENGTH = (E_BASE + 13); 116 117 /** 118 * @brief The error code for the value exceeds the max length (16 * 1024 * 1024 ). 119 */ 120 constexpr int E_VALUE_EXCEED_MAX_LENGTH = (E_BASE + 14); 121 122 /** 123 * @brief The error code for the key exceeds the length limit (32). 124 */ 125 constexpr int E_KEY_EXCEED_LENGTH_LIMIT = (E_BASE + 15); 126 127 /** 128 * @brief The error code for the value exceeds the length limit (128). 129 */ 130 constexpr int E_VALUE_EXCEED_LENGTH_LIMIT = (E_BASE + 16); 131 132 /** 133 * @brief The error code for the default exceeds the max length (128). 134 */ 135 constexpr int E_DEFAULT_EXCEED_LENGTH_LIMIT = (E_BASE + 17); 136 137 /** 138 * @brief The error code for permission denied. 139 */ 140 constexpr int PERMISSION_DENIED = (E_BASE + 18); 141 142 /** 143 * @brief Failed to get DataObsMgrClient. 144 */ 145 static constexpr int E_GET_DATAOBSMGRCLIENT_FAIL = (E_BASE + 19); 146 147 /** 148 * @brief The error code is used to retain the observer. 149 */ 150 constexpr int E_OBSERVER_RESERVE = (E_BASE + 20); 151 152 /** 153 * @brief The error code is used to indicate that database has been closed. 154 */ 155 constexpr int E_ALREADY_CLOSED = (E_BASE + 21); 156 157 /** 158 * @brief The error code is used to indicate that database has been closed. 159 */ 160 constexpr int E_NO_DATA = (E_BASE + 22); 161 } // namespace NativePreferences 162 } // namespace OHOS 163 #endif // PREFERENCES_ERRNO_H 164