forked from hyperledger-iroha/iroha-dco
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: motxx <[email protected]>
- Loading branch information
Showing
17 changed files
with
154 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
shared_model/interfaces/query_responses/abstract_error_response.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
|
||
/** | ||
* Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved. | ||
* http://soramitsu.co.jp | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef IROHA_ABSTRACT_ERROR_RESPONSE_HPP | ||
#define IROHA_ABSTRACT_ERROR_RESPONSE_HPP | ||
|
||
#include "interfaces/primitive.hpp" | ||
#include "model/queries/responses/error_response.hpp" | ||
#include "utils/string_builder.hpp" | ||
|
||
namespace shared_model { | ||
namespace interface { | ||
/** | ||
* Abstract error response | ||
* @tparam Model - concrete model error response | ||
*/ | ||
template <typename Model> | ||
class AbstractErrorResponse | ||
: public Primitive<Model, iroha::model::ErrorResponse> { | ||
private: | ||
/** | ||
* @return string representation of error reason | ||
*/ | ||
virtual std::string reason() const = 0; | ||
|
||
/** | ||
* @return old model error reason | ||
*/ | ||
virtual iroha::model::ErrorResponse::Reason oldModelReason() const = 0; | ||
|
||
public: | ||
// ------------------------| Primitive override |------------------------- | ||
|
||
std::string toString() const override { | ||
return detail::PrettyStringBuilder().init(reason()).finalize(); | ||
} | ||
|
||
iroha::model::ErrorResponse *makeOldModel() const override { | ||
auto error_reponse = new iroha::model::ErrorResponse(); | ||
error_reponse->reason = oldModelReason(); | ||
return error_reponse; | ||
} | ||
|
||
bool operator==(const Model &rhs) const override { return true; } | ||
}; | ||
} // namespace interface | ||
} // namespace shared_model | ||
|
||
#endif // IROHA_ABSTRACT_ERROR_RESPONSE_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.