std::system...system_error(3)
π NAME π
std::system_error::system_error - std::system_error::system_error
okay so bestie, this is std::system...system_error(3) from the C++ Standard Libary manual β yes, thatβs the manual name, and the page is literally giving the same std::system_error::system_error on both sides of the dash ππ
. iconic, mysterious, a little redundant, we love her.
β¨ Synopsis β¨
system_error( std::error_code ec ); (1)
(since C++11)
system_error( std::error_code ec, const std::string& what_arg ); (2)
(since C++11)
system_error( std::error_code ec, const char* what_arg ); (2)
(since C++11)
system_error( int ev, const std::error_category& ecat ); (3)
(since C++11)
system_error( int ev, const std::error_category& ecat, (4)
(since C++11)
const std::string& what_arg );
system_error( int ev, const std::error_category& ecat, (4)
(since C++11)
const char* what_arg );
system_error( const system_error& other ) noexcept; (5)
(since C++11)
Constructs new system error object. thatβs the whole assignment, no cap β¨:
- Constructs with error code
ec. - Constructs with error code
ecand explanation stringwhat_arg. The string returned bywhat()is guaranteed to containwhat_argas a substring. - Constructs with underlying error code
evand associated error categoryecat. - Constructs with underlying error code
ev, associated error categoryecatand explanatory stringwhat_arg. The string returned bywhat()is guaranteed to containwhat_argas a substring (assuming that it doesn't contain an embedded null character). - Copy constructor. Initializes the contents with those of
other. If*thisandotherboth have dynamic typestd::system_errorthenstd::strcmp(what(), other.what()) == 0.
π Parameters π
ecβ error code.evβ underlying error code in the enumeration associated withecat.ecatβ the category of error.what_argβ explanatory string.otherβ anothersystem_errorto copy.
π» Example π»
Demonstrates how to create a system_error exception from an errno value. yes bestie, error-handling main character energy π₯.
The page even hits you with // Run this code right before the snippet:
#include <iostream>
#include <system_error>
int main()
{
try
{
throw std::system_error(EDOM, std::generic_category(), "FIX ME");
}
catch (const std::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]
mwah π this page is from http://cppreference.com, dated 2024.06.10, and the footer calls it std::system...system_error(3) β periodt. πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms