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 #include "object_error.h" 17 18 namespace OHOS { 19 namespace ObjectStore { 20 static constexpr int EXCEPTION_DEVICE_NOT_SUPPORT = 801; 21 static constexpr int EXCEPTION_PARAMETER_CHECK = 401; 22 static constexpr int EXCEPTION_NO_PERMISSION = 201; 23 static constexpr int EXCEPTION_DB_EXIST = 15400001; 24 GetMessage()25std::string ParametersType::GetMessage() 26 { 27 return "Parameter error. The type of '" + name + "' must be '" + wantType + "'."; 28 } 29 GetCode()30int ParametersType::GetCode() 31 { 32 return EXCEPTION_PARAMETER_CHECK; 33 } 34 GetMessage()35std::string ParametersNum::GetMessage() 36 { 37 return "Parameter error. Need " + wantNum + " parameters!"; 38 } 39 GetCode()40int ParametersNum::GetCode() 41 { 42 return EXCEPTION_PARAMETER_CHECK; 43 } 44 GetMessage()45std::string PermissionError::GetMessage() 46 { 47 return "Permission verification failed. An attempt was made to join session forbidden by permission: " 48 "ohos.permission.DISTRIBUTED_DATASYNC."; 49 } 50 GetCode()51int DatabaseError::GetCode() 52 { 53 return EXCEPTION_DB_EXIST; 54 } 55 GetMessage()56std::string DatabaseError::GetMessage() 57 { 58 return "Failed to create the in-memory database. The possible reason is that other distributed data object" 59 " has already set the same sessionId."; 60 } 61 GetCode()62int PermissionError::GetCode() 63 { 64 return EXCEPTION_NO_PERMISSION; 65 } 66 GetMessage()67std::string InnerError::GetMessage() 68 { 69 return ""; 70 } 71 GetCode()72int InnerError::GetCode() 73 { 74 return EXCEPTION_INNER; 75 } 76 GetMessage()77std::string DeviceNotSupportedError::GetMessage() 78 { 79 return "Capability not supported."; 80 } 81 GetCode()82int DeviceNotSupportedError::GetCode() 83 { 84 return EXCEPTION_DEVICE_NOT_SUPPORT; 85 } 86 } // namespace ObjectStore 87 } // namespace OHOS