std::system_error (3) - Linux Manuals
std::system_error: std::system_error
Command to display std::system_error
manual in Linux: $ man 3 std::system_error
NAME
std::system_error - std::system_error
Synopsis
Defined in header <system_error>
class system_error; (since C++11)
std::system_error is the type of the exception thrown by various library functions (typically the functions that interface with the OS facilities, e.g. the constructor of std::thread) when the exception has an associated std::error_code, which may be reported.
std-system error-inheritance.svg
Inheritance diagram
Member functions
constructs the system_error object
constructor (public member function)
returns error code
code (public member function)
what returns explanatory string
(virtual public member function)
[virtual]
Inherited from std::exception
Member functions
destructor destroys the exception object
(virtual public member function of std::exception)
[virtual]
what returns an explanatory string
(virtual public member function of std::exception)
[virtual]
Example
// Run this code
#include <thread>
#include <iostream>
#include <system_error>
int main()
{
try {
std::thread().detach(); // attempt to detach a non-thread
} catch(const std::system_error& e) {
std::cout << "Caught system_error with code " << e.code()
<< " meaning " << e.what() << '\n';
}
}
Output:
Caught system_error with code generic:22 meaning Invalid argument
Pages related to std::system_error
- std::system_error::code (3) - std::system_error::code
- std::system_error::system_error (3) - std::system_error::system_error
- std::system_error::what (3) - std::system_error::what
- std::system_category (3) - std::system_category
- std::system (3) - std::system
- std::sample (3) - std::sample
- std::scalbn,std::scalbnf,std::scalbnl,std::scalbln,std::scalblnf,std::scalblnl (3) - std::scalbn,std::scalbnf,std::scalbnl,std::scalbln,std::scalblnf,std::scalblnl
- std::scanf,std::fscanf,std::sscanf (3) - std::scanf,std::fscanf,std::sscanf
- std::scoped_allocator_adaptor (3) - std::scoped_allocator_adaptor
- std::scoped_allocator_adaptor<OuterAlloc,InnerAlloc...>::allocate (3) - std::scoped_allocator_adaptor<OuterAlloc,InnerAlloc...>::allocate