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."; 59 } 60 GetCode()61int PermissionError::GetCode() 62 { 63 return EXCEPTION_NO_PERMISSION; 64 } 65 GetMessage()66std::string InnerError::GetMessage() 67 { 68 return ""; 69 } 70 GetCode()71int InnerError::GetCode() 72 { 73 return EXCEPTION_INNER; 74 } 75 GetMessage()76std::string DeviceNotSupportedError::GetMessage() 77 { 78 return "Capability not supported."; 79 } 80 GetCode()81int DeviceNotSupportedError::GetCode() 82 { 83 return EXCEPTION_DEVICE_NOT_SUPPORT; 84 } 85 } // namespace ObjectStore 86 } // namespace OHOS