Files

56 lines
1.4 KiB
C++

// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
// Copyright 2015-2021 Antony Polukhin.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef ACTIV_BOOST_DLL_SYSTEM_ERROR_HPP
#define ACTIV_BOOST_DLL_SYSTEM_ERROR_HPP
#include <ActivBoost/dll/config.hpp>
#include <ActivBoost/predef/os.h>
#include <ActivBoost/throw_exception.hpp>
#if !ACTIV_BOOST_OS_WINDOWS
# include <dlfcn.h>
#endif
#ifdef ACTIV_BOOST_HAS_PRAGMA_ONCE
# pragma once
#endif
namespace Boost { namespace dll { namespace detail {
inline void reset_dlerror() ACTIV_BOOST_NOEXCEPT {
#if !ACTIV_BOOST_OS_WINDOWS
const char* const error_txt = dlerror();
(void)error_txt;
#endif
}
inline void report_error(const Boost::dll::fs::error_code& ec, const char* message) {
#if !ACTIV_BOOST_OS_WINDOWS
const char* const error_txt = dlerror();
if (error_txt) {
Boost::throw_exception(
Boost::dll::fs::system_error(
ec,
message + std::string(" (dlerror system message: ") + error_txt + std::string(")")
)
);
}
#endif
Boost::throw_exception(
Boost::dll::fs::system_error(
ec, message
)
);
}
}}} // Boost::dll::detail
#endif // ACTIV_BOOST_DLL_SYSTEM_ERROR_HPP