2 //===----------------------------------------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___SYSTEM_ERROR_SYSTEM_ERROR_H
11 #define _LIBCPP___SYSTEM_ERROR_SYSTEM_ERROR_H
14 #include <__system_error/error_category.h>
15 #include <__system_error/error_code.h>
16 #include <__verbose_abort>
20 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21 # pragma GCC system_header
24 _LIBCPP_BEGIN_NAMESPACE_STD
26 class _LIBCPP_EXPORTED_FROM_ABI system_error
: public runtime_error
{
30 system_error(error_code __ec
, const string
& __what_arg
);
31 system_error(error_code __ec
, const char* __what_arg
);
32 system_error(error_code __ec
);
33 system_error(int __ev
, const error_category
& __ecat
, const string
& __what_arg
);
34 system_error(int __ev
, const error_category
& __ecat
, const char* __what_arg
);
35 system_error(int __ev
, const error_category
& __ecat
);
36 _LIBCPP_HIDE_FROM_ABI
system_error(const system_error
&) _NOEXCEPT
= default;
37 ~system_error() _NOEXCEPT override
;
39 _LIBCPP_HIDE_FROM_ABI
const error_code
& code() const _NOEXCEPT
{ return __ec_
; }
42 [[__noreturn__
]] _LIBCPP_HIDE_FROM_ABI
inline void __throw_system_error(error_code __ec
, const char* __what_arg
) {
43 #if _LIBCPP_HAS_EXCEPTIONS
44 throw system_error(__ec
, __what_arg
);
46 _LIBCPP_VERBOSE_ABORT(
47 "system_error was thrown in -fno-exceptions mode with error %i and message \"%s\"", __ec
.value(), __what_arg
);
51 _LIBCPP_END_NAMESPACE_STD
53 #endif // _LIBCPP___SYSTEM_ERROR_SYSTEM_ERROR_H