throw_on_error.hpp 930 B

123456789101112131415161718192021222324252627282930
  1. //
  2. // Copyright (c) 2019-2024 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. #ifndef BOOST_MYSQL_THROW_ON_ERROR_HPP
  8. #define BOOST_MYSQL_THROW_ON_ERROR_HPP
  9. #include <boost/mysql/detail/throw_on_error_loc.hpp>
  10. namespace boost {
  11. namespace mysql {
  12. /**
  13. * \brief Throws an exception in case of error, including diagnostic information.
  14. * \details If err indicates a failure (`err.failed() == true`), throws an exception that
  15. * derives from \ref error_with_diagnostics. The exception will make
  16. * `diag` available in \ref error_with_diagnostics::get_diagnostics.
  17. */
  18. inline void throw_on_error(error_code err, const diagnostics& diag = {})
  19. {
  20. detail::throw_on_error_loc(err, diag, boost::source_location{});
  21. }
  22. } // namespace mysql
  23. } // namespace boost
  24. #endif