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