19 Diagnostics library [diagnostics]

19.5 System error support [syserr]

19.5.6 Class system_error [syserr.syserr]

19.5.6.1 Class system_error overview [syserr.syserr.overview]

The class system_error describes an exception object used to report error conditions that have an associated error code. Such error conditions typically originate from the operating system or other low-level application program interfaces.

Note: If an error represents an out-of-memory condition, implementations are encouraged to throw an exception object of type bad_alloc [bad.alloc] rather than system_error.  — end note ]

namespace std {
  class system_error : public runtime_error {
  public:
    system_error(error_code ec, const string& what_arg);
    system_error(error_code ec, const char* what_arg);
    system_error(error_code ec);
    system_error(int ev, const error_category& ecat,
        const string& what_arg);
    system_error(int ev, const error_category& ecat,
        const char* what_arg);
    system_error(int ev, const error_category& ecat);
    const error_code& code() const noexcept;
    const char* what() const noexcept;
  };
}   // namespace std

19.5.6.2 Class system_error members [syserr.syserr.members]

system_error(error_code ec, const string& what_arg);

Effects: Constructs an object of class system_error.

Postconditions: code() == ec.

string(what()).find(what_arg) != string::npos.

system_error(error_code ec, const char* what_arg);

Effects: Constructs an object of class system_error.

Postconditions: code() == ec.

string(what()).find(what_arg) != string::npos.

system_error(error_code ec);

Effects: Constructs an object of class system_error.

Postconditions: code() == ec.

system_error(int ev, const error_category& ecat, const string& what_arg);

Effects: Constructs an object of class system_error.

Postconditions: code() == error_code(ev, ecat).

string(what()).find(what_arg) != string::npos.

system_error(int ev, const error_category& ecat, const char* what_arg);

Effects: Constructs an object of class system_error.

Postconditions: code() == error_code(ev, ecat).

string(what()).find(what_arg) != string::npos.

system_error(int ev, const error_category& ecat);

Effects: Constructs an object of class system_error.

Postconditions: code() == error_code(ev, ecat).

const error_code& code() const noexcept;

Returns: ec or error_code(ev, ecat), from the constructor, as appropriate.

const char* what() const noexcept;

Returns: An ntbs incorporating the arguments supplied in the constructor.

Note: The returned NTBS might be the contents of what_arg + ": " + code.message(). — end note ]