|
|
|
|
Member functions | ||||
system_error::system_error | ||||
system_error(std::error_code ec); | (1) | (since C++11) |
system_error(std::error_code ec,conststd::string& what_arg); | (2) | (since C++11) |
system_error(std::error_code ec,constchar* what_arg); | (2) | (since C++11) |
system_error(int ev,conststd::error_category& ecat); | (3) | (since C++11) |
system_error(int ev,conststd::error_category& ecat, conststd::string& what_arg); | (4) | (since C++11) |
system_error(int ev,conststd::error_category& ecat, constchar* what_arg); | (4) | (since C++11) |
system_error(const system_error& other)noexcept; | (5) | (since C++11) |
Constructs new system error object.
std::system_error
thenstd::strcmp(what(), other.what())==0.ec | - | error code |
ev | - | underlying error code in the enumeration associated withecat |
ecat | - | the category of error |
what_arg | - | explanatory string |
other | - | anothersystem_error to copy |
Demonstrates how to create asystem_error
exception from anerrno value.
#include <iostream>#include <system_error> int main(){try{throwstd::system_error(EDOM,std::generic_category(),"FIX ME");}catch(conststd::system_error& ex){std::cout<<"code: ["<< ex.code()<<"]\n""message: ["<< ex.code().message()<<"]\n""what: ["<< ex.what()<<"]\n";}}
Possible output:
code: [generic:33]message: [Numerical argument out of domain]what: [FIX ME: Numerical argument out of domain]