Files
cppdraft_translate/cppdraft/syserr/syserr.md
2025-10-25 03:02:53 +03:00

4.5 KiB
Raw Blame History

[syserr.syserr]

19 Diagnostics library [diagnostics]

19.5 System error support [syserr]

19.5.8 Class system_error [syserr.syserr]

19.5.8.1 Overview [syserr.syserr.overview]

1

#

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.

2

#

[Note 1:

If an error represents an out-of-memory condition, implementations are encouraged to throw an exception object of type 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 override; };}

19.5.8.2 Members [syserr.syserr.members]

🔗

system_error(error_code ec, const string& what_arg);

1

#

Postconditions: code() == ec and
string_view(what()).find(what_arg.c_str()) != string_view::npos.

🔗

system_error(error_code ec, const char* what_arg);

2

#

Postconditions: code() == ec andstring_view(what()).find(what_arg) != string_view::npos.

🔗

system_error(error_code ec);

3

#

Postconditions: code() == ec.

🔗

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

4

#

Postconditions: code() == error_code(ev, ecat) and
string_view(what()).find(what_arg.c_str()) != string_view::npos.

🔗

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

5

#

Postconditions: code() == error_code(ev, ecat) and
string_view(what()).find(what_arg) != string_view::npos.

🔗

system_error(int ev, const error_category& ecat);

6

#

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

🔗

const error_code& code() const noexcept;

7

#

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

🔗

const char* what() const noexcept override;

8

#

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

[Note 1:

The returned ntbs might be the contents of what_arg + ": " + code.message().

— end note]