• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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()25 std::string ParametersType::GetMessage()
26 {
27     return "Parameter error. The type of '" + name + "' must be '" + wantType + "'.";
28 }
29 
GetCode()30 int ParametersType::GetCode()
31 {
32     return EXCEPTION_PARAMETER_CHECK;
33 }
34 
GetMessage()35 std::string ParametersNum::GetMessage()
36 {
37     return "Parameter error. Need " + wantNum + " parameters!";
38 }
39 
GetCode()40 int ParametersNum::GetCode()
41 {
42     return EXCEPTION_PARAMETER_CHECK;
43 }
44 
GetMessage()45 std::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()51 int DatabaseError::GetCode()
52 {
53     return EXCEPTION_DB_EXIST;
54 }
55 
GetMessage()56 std::string DatabaseError::GetMessage()
57 {
58     return "Failed to create the in-memory database.";
59 }
60 
GetCode()61 int PermissionError::GetCode()
62 {
63     return EXCEPTION_NO_PERMISSION;
64 }
65 
GetMessage()66 std::string InnerError::GetMessage()
67 {
68     return "";
69 }
70 
GetCode()71 int InnerError::GetCode()
72 {
73     return EXCEPTION_INNER;
74 }
75 
GetMessage()76 std::string DeviceNotSupportedError::GetMessage()
77 {
78     return "Capability not supported.";
79 }
80 
GetCode()81 int DeviceNotSupportedError::GetCode()
82 {
83     return EXCEPTION_DEVICE_NOT_SUPPORT;
84 }
85 } // namespace ObjectStore
86 } // namespace OHOS