1178825Sdfr// -*- C++ -*- 2233294Sstas//===----------------------------------------------------------------------===// 3233294Sstas// 4178825Sdfr// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5233294Sstas// See https://llvm.org/LICENSE.txt for license information. 6178825Sdfr// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7233294Sstas// 8233294Sstas//===----------------------------------------------------------------------===// 9233294Sstas 10178825Sdfr#ifndef _LIBCPP___SYSTEM_ERROR_SYSTEM_ERROR_H 11233294Sstas#define _LIBCPP___SYSTEM_ERROR_SYSTEM_ERROR_H 12233294Sstas 13178825Sdfr#include <__config> 14233294Sstas#include <__system_error/error_category.h> 15233294Sstas#include <__system_error/error_code.h> 16233294Sstas#include <__verbose_abort> 17178825Sdfr#include <stdexcept> 18233294Sstas#include <string> 19233294Sstas 20233294Sstas#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 21178825Sdfr# pragma GCC system_header 22233294Sstas#endif 23233294Sstas 24233294Sstas_LIBCPP_BEGIN_NAMESPACE_STD 25233294Sstas 26233294Sstasclass _LIBCPP_EXPORTED_FROM_ABI system_error : public runtime_error { 27233294Sstas error_code __ec_; 28233294Sstas 29233294Sstaspublic: 30233294Sstas system_error(error_code __ec, const string& __what_arg); 31233294Sstas system_error(error_code __ec, const char* __what_arg); 32233294Sstas system_error(error_code __ec); 33178825Sdfr system_error(int __ev, const error_category& __ecat, const string& __what_arg); 34178825Sdfr system_error(int __ev, const error_category& __ecat, const char* __what_arg); 35178825Sdfr system_error(int __ev, const error_category& __ecat); 36178825Sdfr _LIBCPP_HIDE_FROM_ABI system_error(const system_error&) _NOEXCEPT = default; 37178825Sdfr ~system_error() _NOEXCEPT override; 38178825Sdfr 39178825Sdfr _LIBCPP_HIDE_FROM_ABI const error_code& code() const _NOEXCEPT { return __ec_; } 40178825Sdfr}; 41178825Sdfr 42178825Sdfr_LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_system_error(int __ev, const char* __what_arg); 43178825Sdfr_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void __throw_system_error(error_code __ec, const char* __what_arg) { 44178825Sdfr#ifndef _LIBCPP_HAS_NO_EXCEPTIONS 45178825Sdfr throw system_error(__ec, __what_arg); 46178825Sdfr#else 47178825Sdfr _LIBCPP_VERBOSE_ABORT( 48178825Sdfr "system_error was thrown in -fno-exceptions mode with error %i and message \"%s\"", __ec.value(), __what_arg); 49178825Sdfr#endif 50233294Sstas} 51233294Sstas 52233294Sstas_LIBCPP_END_NAMESPACE_STD 53233294Sstas 54233294Sstas#endif // _LIBCPP___SYSTEM_ERROR_SYSTEM_ERROR_H 55233294Sstas