◐ Shell
clean mode source ↗

std::system_error - cppreference.com

提供: cppreference.com

<tbody> </tbody>

std::system_error は、様々なライブラリ関数 (一般的には OS の機能とやりとりする関数、例えば std::thread のコンストラクタなど) によって、報告されるかもしれない関連する std::error_code を持つ場合に、投げられる例外の型です。

cpp/error/exceptioncpp/error/runtime error

継承図

メンバ関数

#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';
    }
}

出力:

Caught system_error with code generic:22 meaning Invalid argument