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_ERROR_IMPL_H 17 #define DATASHARE_ERROR_IMPL_H 18 19 #include "datashare_error.h" 20 21 namespace OHOS { 22 namespace DataShare { 23 class ParametersTypeError : public Error { 24 public: ParametersTypeError(const std::string & name,const std::string & wantType)25 ParametersTypeError(const std::string &name, const std::string &wantType) : name(name), wantType(wantType){}; 26 std::string GetMessage() const override; 27 int GetCode() const override; 28 private: 29 std::string name; 30 std::string wantType; 31 }; 32 33 class ParametersNumError : public Error { 34 public: ParametersNumError(const std::string & wantNum)35 ParametersNumError(const std::string &wantNum) : wantNum(wantNum){}; 36 std::string GetMessage() const override; 37 int GetCode() const override; 38 private: 39 std::string wantNum; 40 }; 41 42 class DataShareHelperInitError : public Error { 43 public: 44 DataShareHelperInitError() = default; 45 std::string GetMessage() const override; 46 int GetCode() const override; 47 }; 48 49 class InnerError : public Error { 50 public: 51 InnerError() = default; 52 std::string GetMessage() const override; 53 int GetCode() const override; 54 }; 55 56 class BusinessError : public Error { 57 public: BusinessError(int code,const std::string & message)58 BusinessError(int code, const std::string &message) : code_(code), message_(message){}; 59 std::string GetMessage() const override; 60 int GetCode() const override; 61 62 private: 63 int code_ = E_OK; 64 std::string message_ = ""; 65 }; 66 67 class UriNotExistError : public Error { 68 public: 69 UriNotExistError() = default; 70 std::string GetMessage() const override; 71 int GetCode() const override; 72 }; 73 74 class DataAreaNotExistError : public Error { 75 public: 76 DataAreaNotExistError() = default; 77 std::string GetMessage() const override; 78 int GetCode() const override; 79 }; 80 81 class HelperAlreadyClosedError : public Error { 82 public: 83 HelperAlreadyClosedError() = default; 84 std::string GetMessage() const override; 85 int GetCode() const override; 86 }; 87 } // namespace DataShare 88 } // namespace OHOS 89 #endif // DATASHARE_ERROR_IMPL_H 90