const char* what() const noexcept override;
概要
エラー理由の文字列を取得する。
戻り値
コンストラクタで設定されたエラー理由の文字列を返す。
例
#include <iostream> #include <filesystem> namespace fs = std::filesystem; int main() { try { throw fs::filesystem_error( "can't copy file. source file doesn't found", std::make_error_code(std::errc::no_such_file_or_directory) ); } catch (fs::filesystem_error& err) { std::cout << err.what() << std::endl; } }
出力例
filesystem error: can't copy file. source file doesn't found: No such file or directory
バージョン
言語
- C++17
処理系
- Clang:
- GCC: 8.1
- Visual C++: