Kagome
Polkadot Runtime Engine in C++17
outcome_throw.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CORE_COMMON_OUTCOME_THROW_HPP
7 #define KAGOME_CORE_COMMON_OUTCOME_THROW_HPP
8 
9 #include <boost/system/system_error.hpp>
10 #include <boost/throw_exception.hpp>
11 
12 namespace kagome::common {
18  template <typename T, typename = std::enable_if_t<std::is_enum_v<T>>>
19  void raise(T t) {
20  std::error_code ec = make_error_code(t);
21  boost::throw_exception(std::system_error(ec));
22  }
23 
29  template <typename T, typename = std::enable_if_t<!std::is_enum_v<T>>>
30  void raise(const T &t) {
31  boost::throw_exception(std::system_error(t.value(), t.category()));
32  }
33 } // namespace kagome::common
34 
35 #endif // KAGOME_CORE_COMMON_OUTCOME_THROW_HPP