std::system_error
From cppreference.com
| ヘッダー <system_error> で定義 |
||
| class system_error; |
(C++11以降) | |
std::system_error は、例外が報告可能な関連する std::error_code を持つ場合に、さまざまなライブラリ関数(通常はOS機能とインターフェースする関数、例:std::thread のコンストラクタ)によってスローされる例外の型です。
継承図
目次 |
[編集] メンバ関数
system_error オブジェクトを構築します(public member function) [[編集]] | |
system_error オブジェクトを置き換えます(public member function) [[編集]] | |
| エラーコードを返します。 (public member function) [[編集]] | |
| [virtual] |
説明文字列を返す (virtual public member function) [[編集]] |
std::exception から継承
メンバ関数
| [virtual] |
例外オブジェクトを破棄する ( std::exception の仮想 public メンバー関数) |
| [virtual] |
説明文字列を返す ( std::exception の仮想 public メンバー関数) |
[編集] 例
このコードを実行
#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"; } }
実行結果の例
Caught system_error with code [generic:22] meaning [Invalid argument]