| (1) | (since C++11) | ||
| (2) | (since C++11) | ||
| (2) | (since C++11) | ||
| (3) | (since C++11) | ||
| (4) | (since C++11) | ||
| (4) | (since C++11) |
Constructs new system error object.
1) Constructs with error code
ec
2) Constructs with error code
ec
and explanation string what_arg
. The string returned by what()
is guaranteed to contain what_arg
. 3) Constructs with underlying error code
ev
and associated error category ecat
. 4) Constructs with underlying error code
ev
, associated error category ecat
and explanatory string what_arg
. The string returned by what()
is guaranteed to contain what_arg
.Parameters
ec | - | error code |
ev | - | error code in base encoding |
ecat | - | the category of error |
what_arg | - | explanatory string |
Example
Demonstrates how to create a system_error exception from a errno value.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #include <iostream> #include <system_error> int main() { try { throw std::system_error(EDOM, std::system_category()); } catch ( const std::system_error& error) { std::cout << "Error: " << error.code() << " - " << error.code().message() << '\n' ; } } |
Output:
1 | Error: system :33 - Numerical argument out of domain |
Please login to continue.