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 DataProxyHandleParamError : public Error { 43 public: 44 DataProxyHandleParamError() = default; 45 std::string GetMessage() const override; 46 int GetCode() const override; 47 }; 48 49 class DataShareHelperInitError : public Error { 50 public: 51 DataShareHelperInitError() = default; 52 std::string GetMessage() const override; 53 int GetCode() const override; 54 }; 55 56 class InnerError : public Error { 57 public: 58 InnerError() = default; 59 std::string GetMessage() const override; 60 int GetCode() const override; 61 }; 62 63 class BusinessError : public Error { 64 public: BusinessError(int code,const std::string & message)65 BusinessError(int code, const std::string &message) : code_(code), message_(message){}; 66 std::string GetMessage() const override; 67 int GetCode() const override; 68 69 private: 70 int code_ = E_OK; 71 std::string message_ = ""; 72 }; 73 74 class UriNotExistError : public Error { 75 public: 76 UriNotExistError() = default; 77 std::string GetMessage() const override; 78 int GetCode() const override; 79 }; 80 81 class DataAreaNotExistError : public Error { 82 public: 83 DataAreaNotExistError() = default; 84 std::string GetMessage() const override; 85 int GetCode() const override; 86 }; 87 88 class HelperAlreadyClosedError : public Error { 89 public: 90 HelperAlreadyClosedError() = default; 91 std::string GetMessage() const override; 92 int GetCode() const override; 93 }; 94 } // namespace DataShare 95 } // namespace OHOS 96 #endif // DATASHARE_ERROR_IMPL_H 97