throw_on_error.hpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (c) 2006, 2007 Julio M. Merino Vidal
  2. // Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
  3. // Copyright (c) 2009 Boris Schaeling
  4. // Copyright (c) 2010 Felipe Tanus, Boris Schaeling
  5. // Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
  6. // Copyright (c) 2016 Klemens D. Morgenstern
  7. //
  8. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  9. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  10. #ifndef BOOST_PROCESS_DETAIL_INITIALIZERS_THROW_ON_ERROR_HPP
  11. #define BOOST_PROCESS_DETAIL_INITIALIZERS_THROW_ON_ERROR_HPP
  12. #include <boost/process/detail/config.hpp>
  13. #include <boost/process/detail/handler_base.hpp>
  14. namespace boost { namespace process { namespace detail {
  15. struct throw_on_error_ : ::boost::process::detail::handler
  16. {
  17. template <class Executor>
  18. void on_error(Executor& exec, const std::error_code & ec) const
  19. {
  20. throw process_error(ec, "process creation failed");
  21. }
  22. const throw_on_error_ &operator()() const {return *this;}
  23. };
  24. }
  25. constexpr boost::process::detail::throw_on_error_ throw_on_error;
  26. }}
  27. #endif