hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
validation_error_helpers.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_VALIDATION_ERROR_HELPERS_HPP
7 #define IROHA_VALIDATION_ERROR_HELPERS_HPP
8 
9 #include <boost/optional/optional.hpp>
11 
12 namespace shared_model {
13  namespace validation {
14 
17  public:
22  boost::optional<ValidationError> getValidationError(
23  const ReasonName &name) &&;
24 
30  template <typename NameProvider>
31  boost::optional<ValidationError> getValidationErrorWithGeneratedName(
32  NameProvider &&name_provider) && {
33  if (optional_error_) {
34  optional_error_->name = std::forward<NameProvider>(name_provider)();
35  }
36  return std::move(optional_error_);
37  }
38 
41 
44 
47  boost::optional<ReasonType> optional_reason);
48 
51  boost::optional<ValidationError> optional_error);
52 
53  private:
54  ValidationError &getOrCreateValidationError();
55 
56  boost::optional<ValidationError> optional_error_;
57  };
58 
59  boost::optional<ValidationError> operator|(
60  boost::optional<ValidationError> oe1,
61  boost::optional<ValidationError> oe2);
62 
71  boost::optional<ValidationError> aggregateErrors(
72  const ReasonName &name,
73  std::vector<boost::optional<ReasonType>> optional_reasons,
74  std::vector<boost::optional<ValidationError>> optional_child_errors);
75 
76  } // namespace validation
77 } // namespace shared_model
78 
79 #endif
ValidationErrorCreator & addChildError(ValidationError error)
Add a child error.
Definition: validation_error_helpers.cpp:28
boost::optional< ValidationError > operator|(boost::optional< ValidationError > oe1, boost::optional< ValidationError > oe2)
Definition: validation_error_helpers.cpp:71
Represents a validation error.
Definition: validation_error.hpp:19
boost::optional< ValidationError > getValidationError(const ReasonName &name) &&
Definition: validation_error_helpers.cpp:15
std::string ReasonType
Definition: validation_error.hpp:15
ValidationErrorCreator & addReason(ReasonType reason)
Add a reason to error.
Definition: validation_error_helpers.cpp:23
boost::optional< ValidationError > getValidationErrorWithGeneratedName(NameProvider &&name_provider) &&
Definition: validation_error_helpers.hpp:31
Helper class for ValidationError creation.
Definition: validation_error_helpers.hpp:16
boost::optional< ValidationError > aggregateErrors(const ReasonName &name, std::vector< boost::optional< ReasonType >> optional_reasons, std::vector< boost::optional< ValidationError >> optional_child_errors)
Definition: validation_error_helpers.cpp:57
ValidationErrorCreator & operator|=(boost::optional< ReasonType > optional_reason)
Add a reason, if any.
Definition: validation_error_helpers.cpp:34
std::string ReasonName
Definition: validation_error.hpp:16
Definition: command_executor.hpp:12