142 lines
4.5 KiB
Markdown
142 lines
4.5 KiB
Markdown
[syserr.syserr]
|
||
|
||
# 19 Diagnostics library [[diagnostics]](./#diagnostics)
|
||
|
||
## 19.5 System error support [[syserr]](syserr#syserr)
|
||
|
||
### 19.5.8 Class system_error [syserr.syserr]
|
||
|
||
#### [19.5.8.1](#overview) Overview [[syserr.syserr.overview]](syserr.syserr.overview)
|
||
|
||
[1](#overview-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1518)
|
||
|
||
The class system_error describes an exception object used to
|
||
report error conditions that have an associated error code[.](#overview-1.sentence-1)
|
||
|
||
Such error
|
||
conditions typically originate from the operating system or other low-level
|
||
application program interfaces[.](#overview-1.sentence-2)
|
||
|
||
[2](#overview-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1524)
|
||
|
||
[*Note [1](#overview-note-1)*:
|
||
|
||
If an error represents an out-of-memory condition, implementations are
|
||
encouraged to throw an exception object of type [bad_alloc](bad.alloc "17.6.4.1 Class bad_alloc [bad.alloc]") rather
|
||
than system_error[.](#overview-2.sentence-1)
|
||
|
||
â *end note*]
|
||
|
||
[ð](#lib:system_error)
|
||
|
||
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) Members [[syserr.syserr.members]](syserr.syserr.members)
|
||
|
||
[ð](#lib:system_error,constructor)
|
||
|
||
`system_error(error_code ec, const string& what_arg);
|
||
`
|
||
|
||
[1](#members-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1555)
|
||
|
||
*Postconditions*: code() == ec and
|
||
string_view(what()).find(what_arg.c_str()) != string_view::npos[.](#members-1.sentence-1)
|
||
|
||
[ð](#lib:system_error,constructor_)
|
||
|
||
`system_error(error_code ec, const char* what_arg);
|
||
`
|
||
|
||
[2](#members-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1567)
|
||
|
||
*Postconditions*: code() == ec andstring_view(what()).find(what_arg) != string_view::npos[.](#members-2.sentence-1)
|
||
|
||
[ð](#lib:system_error,constructor__)
|
||
|
||
`system_error(error_code ec);
|
||
`
|
||
|
||
[3](#members-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1579)
|
||
|
||
*Postconditions*: code() == ec[.](#members-3.sentence-1)
|
||
|
||
[ð](#lib:system_error,constructor___)
|
||
|
||
`system_error(int ev, const error_category& ecat, const string& what_arg);
|
||
`
|
||
|
||
[4](#members-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1590)
|
||
|
||
*Postconditions*: code() == error_code(ev, ecat) and
|
||
string_view(what()).find(what_arg.c_str()) != string_view::npos[.](#members-4.sentence-1)
|
||
|
||
[ð](#lib:system_error,constructor____)
|
||
|
||
`system_error(int ev, const error_category& ecat, const char* what_arg);
|
||
`
|
||
|
||
[5](#members-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1602)
|
||
|
||
*Postconditions*: code() == error_code(ev, ecat) and
|
||
string_view(what()).find(what_arg) != string_view::npos[.](#members-5.sentence-1)
|
||
|
||
[ð](#lib:system_error,constructor_____)
|
||
|
||
`system_error(int ev, const error_category& ecat);
|
||
`
|
||
|
||
[6](#members-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1614)
|
||
|
||
*Postconditions*: code() == error_code(ev, ecat)[.](#members-6.sentence-1)
|
||
|
||
[ð](#lib:code,system_error)
|
||
|
||
`const error_code& code() const noexcept;
|
||
`
|
||
|
||
[7](#members-7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1625)
|
||
|
||
*Returns*: ec or error_code(ev, ecat), from the constructor,
|
||
as appropriate[.](#members-7.sentence-1)
|
||
|
||
[ð](#lib:what,system_error)
|
||
|
||
`const char* what() const noexcept override;
|
||
`
|
||
|
||
[8](#members-8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1637)
|
||
|
||
*Returns*: An ntbs incorporating the arguments supplied in the constructor[.](#members-8.sentence-1)
|
||
|
||
[*Note [1](#members-note-1)*:
|
||
|
||
The returned ntbs might be the contents of what_arg + ": " + code.message()[.](#members-8.sentence-2)
|
||
|
||
â *end note*]
|