Line data Source code
1 :
2 : /**
3 : * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved.
4 : * http://soramitsu.co.jp
5 : *
6 : * Licensed under the Apache License, Version 2.0 (the "License");
7 : * you may not use this file except in compliance with the License.
8 : * You may obtain a copy of the License at
9 : *
10 : * http://www.apache.org/licenses/LICENSE-2.0
11 : *
12 : * Unless required by applicable law or agreed to in writing, software
13 : * distributed under the License is distributed on an "AS IS" BASIS,
14 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 : * See the License for the specific language governing permissions and
16 : * limitations under the License.
17 : */
18 :
19 : #ifndef IROHA_ABSTRACT_ERROR_RESPONSE_HPP
20 : #define IROHA_ABSTRACT_ERROR_RESPONSE_HPP
21 :
22 : #include "interfaces/base/model_primitive.hpp"
23 : #include "utils/string_builder.hpp"
24 :
25 : namespace shared_model {
26 : namespace interface {
27 : /**
28 : * Abstract error response
29 : * @tparam Model - concrete model error response
30 : */
31 : template <typename Model>
32 : class AbstractErrorResponse : public ModelPrimitive<Model> {
33 : private:
34 : /**
35 : * @return string representation of error reason
36 : */
37 : virtual std::string reason() const = 0;
38 :
39 : public:
40 : // ------------------------| Primitive override |-------------------------
41 :
42 : std::string toString() const override {
43 0 : return detail::PrettyStringBuilder().init(reason()).finalize();
44 0 : }
45 :
46 : bool operator==(const Model &rhs) const override {
47 0 : return true;
48 : }
49 : };
50 : } // namespace interface
51 : } // namespace shared_model
52 :
53 : #endif // IROHA_ABSTRACT_ERROR_RESPONSE_HPP
|