throw_on_error_loc.hpp 852 B

123456789101112131415161718192021222324252627282930313233
  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_DETAIL_THROW_ON_ERROR_LOC_HPP
  8. #define BOOST_MYSQL_DETAIL_THROW_ON_ERROR_LOC_HPP
  9. #include <boost/mysql/diagnostics.hpp>
  10. #include <boost/mysql/error_code.hpp>
  11. #include <boost/mysql/error_with_diagnostics.hpp>
  12. #include <boost/assert/source_location.hpp>
  13. namespace boost {
  14. namespace mysql {
  15. namespace detail {
  16. inline void throw_on_error_loc(error_code err, const diagnostics& diag, const source_location& loc)
  17. {
  18. if (err)
  19. {
  20. ::boost::throw_exception(error_with_diagnostics(err, diag), loc);
  21. }
  22. }
  23. } // namespace detail
  24. } // namespace mysql
  25. } // namespace boost
  26. #endif