Skip to content

Commit

Permalink
Use boost::throw_exception
Browse files Browse the repository at this point in the history
Using boost::throw_exception allows for modifications to these
exceptions on a per-application basis, including overriding with custom
implementations.

This also has the benefit of allowing compilation with -fno-exceptions
set, which should make this code more portable.
  • Loading branch information
edtanous committed Jul 11, 2023
1 parent bfb1ebb commit 93eed42
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions include/boost/process/detail/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <system_error>
#include <boost/system/api_config.hpp>

#include <boost/throw_exception.hpp>
#include <boost/process/exception.hpp>

#if defined(BOOST_POSIX_API)
Expand Down Expand Up @@ -73,29 +74,29 @@ inline std::error_code get_last_error() noexcept

inline void throw_last_error(const std::string & msg)
{
throw process_error(get_last_error(), msg);
boost::throw_exception(process_error(get_last_error(), msg));
}

inline void throw_last_error(const char * msg)
{
throw process_error(get_last_error(), msg);
boost::throw_exception(process_error(get_last_error(), msg));
}

inline void throw_last_error()
{
throw process_error(get_last_error());
boost::throw_exception(process_error(get_last_error()));
}

inline void throw_error(const std::error_code& ec)
{
if (ec)
throw process_error(ec);
boost::throw_exception(process_error(ec));
}

inline void throw_error(const std::error_code& ec, const char* msg)
{
if (ec)
throw process_error(ec, msg);
boost::throw_exception(process_error(ec, msg));
}

template<typename Char> constexpr Char null_char();
Expand Down

0 comments on commit 93eed42

Please sign in to comment.