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 "datashare_error_impl.h"
17 
18 namespace OHOS {
19 namespace DataShare {
GetMessage() const20 std::string ParametersTypeError::GetMessage() const
21 {
22     return "Parameter error. The type of '" + name + "' must be '" + wantType + "'.";
23 }
24 
GetCode() const25 int ParametersTypeError::GetCode() const
26 {
27     return EXCEPTION_PARAMETER_CHECK;
28 }
29 
GetMessage() const30 std::string ParametersNumError::GetMessage() const
31 {
32     return "Parameter error. Need " + wantNum + " parameters!";
33 }
34 
GetCode() const35 int ParametersNumError::GetCode() const
36 {
37     return EXCEPTION_PARAMETER_CHECK;
38 }
39 
GetMessage() const40 std::string DataShareHelperInitError::GetMessage() const
41 {
42     return "The DataShareHelper is not initialized successfully.";
43 }
44 
GetCode() const45 int DataShareHelperInitError::GetCode() const
46 {
47     return EXCEPTION_HELPER_UNINITIALIZED;
48 }
49 
GetMessage() const50 std::string InnerError::GetMessage() const
51 {
52     return "Inner error.";
53 }
54 
GetCode() const55 int InnerError::GetCode() const
56 {
57     return EXCEPTION_INNER;
58 }
59 
GetCode() const60 int BusinessError::GetCode() const
61 {
62     return code_;
63 }
64 
GetMessage() const65 std::string BusinessError::GetMessage() const
66 {
67     return message_;
68 }
69 
GetMessage() const70 std::string UriNotExistError::GetMessage() const
71 {
72     return "The URI is not exist.";
73 }
74 
GetCode() const75 int UriNotExistError::GetCode() const
76 {
77     return EXCEPTION_URI_NOT_EXIST;
78 }
79 
GetMessage() const80 std::string DataAreaNotExistError::GetMessage() const
81 {
82     return "The data area is not exist.";
83 }
84 
GetCode() const85 int DataAreaNotExistError::GetCode() const
86 {
87     return EXCEPTION_DATA_AREA_NOT_EXIST;
88 }
89 
GetMessage() const90 std::string HelperAlreadyClosedError::GetMessage() const
91 {
92     return "The DataShareHelper instance is already closed.";
93 }
94 
GetCode() const95 int HelperAlreadyClosedError::GetCode() const
96 {
97     return EXCEPTION_HELPER_CLOSED;
98 }
99 } // namespace DataShare
100 } // namespace OHOS