]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // Copyright 2014 Renato Tegon Forti, Antony Polukhin. |
92f5a8d4 | 2 | // Copyright 2015-2019 Antony Polukhin. |
7c673cae FG |
3 | // |
4 | // Distributed under the Boost Software License, Version 1.0. | |
5 | // (See accompanying file LICENSE_1_0.txt | |
6 | // or copy at http://www.boost.org/LICENSE_1_0.txt) | |
7 | ||
8 | #ifndef BOOST_DLL_SYSTEM_ERROR_HPP | |
9 | #define BOOST_DLL_SYSTEM_ERROR_HPP | |
10 | ||
92f5a8d4 | 11 | #include <boost/dll/config.hpp> |
7c673cae | 12 | #include <boost/predef/os.h> |
7c673cae FG |
13 | #include <boost/throw_exception.hpp> |
14 | ||
15 | #if !BOOST_OS_WINDOWS | |
16 | # include <dlfcn.h> | |
17 | #endif | |
18 | ||
19 | #ifdef BOOST_HAS_PRAGMA_ONCE | |
20 | # pragma once | |
21 | #endif | |
22 | ||
23 | namespace boost { namespace dll { namespace detail { | |
24 | ||
25 | inline void reset_dlerror() BOOST_NOEXCEPT { | |
26 | #if !BOOST_OS_WINDOWS | |
27 | const char* const error_txt = dlerror(); | |
28 | (void)error_txt; | |
29 | #endif | |
30 | } | |
31 | ||
92f5a8d4 | 32 | inline void report_error(const boost::dll::fs::error_code& ec, const char* message) { |
7c673cae FG |
33 | #if !BOOST_OS_WINDOWS |
34 | const char* const error_txt = dlerror(); | |
35 | if (error_txt) { | |
36 | boost::throw_exception( | |
92f5a8d4 | 37 | boost::dll::fs::system_error( |
7c673cae FG |
38 | ec, |
39 | message + std::string(" (dlerror system message: ") + error_txt + std::string(")") | |
40 | ) | |
41 | ); | |
42 | } | |
43 | #endif | |
44 | ||
45 | boost::throw_exception( | |
92f5a8d4 | 46 | boost::dll::fs::system_error( |
7c673cae FG |
47 | ec, message |
48 | ) | |
49 | ); | |
50 | } | |
51 | ||
52 | }}} // boost::dll::detail | |
53 | ||
54 | #endif // BOOST_DLL_SYSTEM_ERROR_HPP | |
55 |