std::system_error
提供: cppreference.com
ヘッダ <system_error> で定義 | ||
class system_error; | (C++11以上) | |
std::system_error
は、様々なライブラリ関数 (一般的には OS の機能とやりとりする関数、例えば std::thread のコンストラクタなど) によって、報告されるかもしれない関連する std::error_code を持つ場合に、投げられる例外の型です。
目次 |
[編集]メンバ関数
system_error オブジェクトを構築します (パブリックメンバ関数) | |
エラーコードを返します (パブリックメンバ関数) | |
[仮想] | 説明文字列を返します (仮想パブリックメンバ関数) |
std::exception から継承
メンバ関数
[仮想] | 例外オブジェクトを破棄します ( std::exception の仮想パブリックメンバ関数) |
[仮想] | 説明文字列を返します ( std::exception の仮想パブリックメンバ関数) |
[編集]例
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';}}
出力:
Caught system_error with code generic:22 meaning Invalid argument