throw_on_error.hpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //
  2. // Copyright (c) 2019-2025 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 (Legacy) Throws an exception in case of error, including diagnostic information.
  14. * \details
  15. * If err indicates a failure (`err.failed() == true`), throws an exception that
  16. * derives from \ref error_with_diagnostics. The exception will make
  17. * `diag` available in \ref error_with_diagnostics::get_diagnostics.
  18. *
  19. * \par Legacy
  20. * The introduction of \ref with_diagnostics obsoletes almost all uses
  21. * of this function. New code should attempt to use \ref with_diagnostics
  22. * instead of manually checking for errors.
  23. */
  24. inline void throw_on_error(error_code err, const diagnostics& diag = {})
  25. {
  26. detail::throw_on_error_loc(err, diag, boost::source_location{});
  27. }
  28. } // namespace mysql
  29. } // namespace boost
  30. #endif