A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/cpp/language/../named_req/../error/system_error.html below:

std::system_error - cppreference.com

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.

Inheritance diagram

[edit] Member functions constructs the system_error object
(public member function) [edit] replaces the system_error object
(public member function) [edit] returns error code
(public member function) [edit] returns an explanatory string
(virtual public member function) [edit] Inherited from std::exception Member functions destroys the exception object
(virtual public member function of std::exception) [edit] returns an explanatory string
(virtual public member function of std::exception) [edit] [edit] Example
#include <iostream>
#include <system_error>
#include <thread>
 
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";
    }
}

Possible output:

Caught system_error with code [generic:22] meaning [Invalid argument]

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4