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 #ifndef DATASHARE_BUSINESS_ERROR_H 17 #define DATASHARE_BUSINESS_ERROR_H 18 19 namespace OHOS { 20 namespace DataShare { 21 class DatashareBusinessError { 22 public: 23 DatashareBusinessError() = default; 24 ~DatashareBusinessError() = default; 25 GetCode()26 int GetCode() 27 { 28 return code_; 29 } 30 SetCode(const std::string & code)31 void SetCode(const std::string &code) 32 { 33 if (!code.empty()) { 34 code_ = atoi(code.c_str()); 35 } 36 } 37 SetCode(int code)38 void SetCode(int code) 39 { 40 code_ = code; 41 } 42 GetMessage()43 std::string GetMessage() 44 { 45 return message_; 46 } 47 SetMessage(const std::string & message)48 void SetMessage(const std::string &message) 49 { 50 message_ = message; 51 } 52 53 static constexpr int DB_NOT_EXIST_ERR = 14800045; 54 55 private: 56 int code_ = 0; 57 std::string message_ = ""; 58 }; 59 } // namespace DataShare 60 } // namespace OHOS 61 #endif // DATASHARE_BUSINESS_ERROR_H