mirror of
https://gitlab.com/fbb-git/cppannotations
synced 2024-11-16 07:48:44 +01:00
Now covering system_error, error_category and -_code
This commit is contained in:
parent
d32206254c
commit
10f56b62e0
5 changed files with 52 additions and 48 deletions
|
@ -1,6 +1,12 @@
|
|||
C++-annotations (9.7.0) WIP
|
||||
|
||||
* Added a section (classes/ambiguity) about Ambiguity Resolution.
|
||||
* Added new section (classes/ambiguity) about Ambiguity Resolution.
|
||||
|
||||
* Added new section 'system_error' (exception/systemerror)
|
||||
|
||||
* Added new section 'the class `error category'' (exception/errorcategory)
|
||||
|
||||
* Added new section 'the class `error code'' (exception/errorcode)
|
||||
|
||||
* Rewrote the section about lamba expressions
|
||||
|
||||
|
|
|
@ -38,6 +38,15 @@ includefile(exceptions/iostreams)
|
|||
lsect(STDEXC)(Standard Exceptions)
|
||||
includefile(exceptions/standard)
|
||||
|
||||
sect(System error, error code and error category (C++11))
|
||||
includefile(exception/systemerror)
|
||||
|
||||
subsect(The class `error_code' (C++11))
|
||||
includefile(exception/errorcode)
|
||||
|
||||
subsect(The class `error_category' (C++11))
|
||||
includefile(exception/errorcategory)
|
||||
|
||||
sect(Exception guarantees)
|
||||
includefile(exceptions/guarantees)
|
||||
|
||||
|
|
|
@ -27,35 +27,35 @@ well. Here is the tt(error_category)'s non-private class interface:
|
|||
class error_category
|
||||
{
|
||||
public:
|
||||
error_category(const error_category&) = delete;
|
||||
error_category(error_category const &) = delete;
|
||||
virtual ~error_category() noexcept;
|
||||
|
||||
error_category& operator=(const error_category&) = delete;
|
||||
error_category& operator=(error_category const &) = delete;
|
||||
|
||||
virtual const char* name() const noexcept = 0;
|
||||
virtual char const *name() const noexcept = 0;
|
||||
virtual string message(int ev) const = 0;
|
||||
|
||||
virtual error_condition
|
||||
default_error_condition(int ev) const noexcept;
|
||||
virtual bool equivalent(
|
||||
int code,
|
||||
const error_condition& condition
|
||||
error_condition const &condition
|
||||
) const noexcept;
|
||||
virtual bool equivalent(
|
||||
const error_code& code,
|
||||
error_code const &code,
|
||||
int condition
|
||||
) const noexcept;
|
||||
|
||||
bool operator==(const error_category& rhs) const noexcept;
|
||||
bool operator!=(const error_category& rhs) const noexcept;
|
||||
bool operator<(const error_category& rhs) const noexcept;
|
||||
bool operator==(error_category const &rhs) const noexcept;
|
||||
bool operator!=(error_category const &rhs) const noexcept;
|
||||
bool operator<(error_category const &rhs) const noexcept;
|
||||
|
||||
protected:
|
||||
error_category() noexcept;
|
||||
|
||||
};
|
||||
const error_category& generic_category() noexcept;
|
||||
const error_category& system_category() noexcept;
|
||||
error_category const &generic_category() noexcept;
|
||||
error_category const &system_category() noexcept;
|
||||
)
|
||||
|
||||
Members:
|
||||
|
|
|
@ -57,33 +57,6 @@ an internal computation results in a value exceeding a permissible range;
|
|||
when a problem is encountered that can only be detected while the program is
|
||||
being executed. Example: a non-integral is entered when the program's input
|
||||
expects an integral value.
|
||||
itht(system_error)(std::system_error): a system error can be thrown when
|
||||
an error occurs that has an associated error code. Such errors are typically
|
||||
encountered when calling low-level (like operating system)
|
||||
functions. tt(system_error) constructors accept an error code in addition to a
|
||||
textual error message. They also offer a member tt(code) returning a const
|
||||
reference to the exception's error code. Here is the class's public interface:
|
||||
verb(
|
||||
class system_error: public runtime_error
|
||||
{
|
||||
public:
|
||||
system_error(error_code ec, string const &what_arg);
|
||||
system_error(error_code ec, char const *what_arg);
|
||||
system_error(error_code ec);
|
||||
system_error(int ev, error_category const &ecat,
|
||||
string const &what_arg);
|
||||
system_error(int ev, error_category const &ecat,
|
||||
char const *what_arg);
|
||||
system_error(int ev, error_category const &ecat);
|
||||
error_code const &code() const noexcept;
|
||||
char const *what() const noexcept;
|
||||
}
|
||||
)
|
||||
The NTBS returned by tt(what) may be formatted like this:
|
||||
verb(
|
||||
what_arg + ": " + code().message()
|
||||
)
|
||||
|
||||
itht(underflow_error)(std::underflow_error): an underflow error should be
|
||||
thrown when an arithmetic underflow is detected. Example: dividing a very
|
||||
small value by a very large value.
|
||||
|
|
|
@ -1,17 +1,33 @@
|
|||
A ti(std::system_error) can be thrown when
|
||||
an error occurs that has an associated error code. Such errors are typically
|
||||
encountered when calling low-level (like operating system)
|
||||
functions.
|
||||
A ti(std::system_error) can be thrown when an error occurs that has an
|
||||
associated error code. Such errors are typically encountered when calling
|
||||
low-level (like operating system) functions.
|
||||
|
||||
Before using tt(system_error) the tthi(system_error) header file must have
|
||||
been included.
|
||||
|
||||
A tt(system_error) can be constructed using the standard textual description
|
||||
of the nature of the encountered error, but in addition accepts an
|
||||
emi(error_code) or emi(error_category) object (see the next two sections),
|
||||
further specifying
|
||||
the nature of the error. The tt(error_code) and tt(error_category) classes are
|
||||
also declared in the tt(system_error) header file.
|
||||
A tt(system_error) object can be constructed using the standard textual
|
||||
description of the nature of the encountered error, but in addition accepts an
|
||||
emi(error_code) or emi(error_category) object (see the next two sections),
|
||||
further specifying the nature of the error. The tt(error_code) and
|
||||
tt(error_category) classes are also declared in the tt(system_error) header
|
||||
file.
|
||||
|
||||
The header file tt(system_error) also defines an ti(enum class errc)hi(errc)
|
||||
whose values are equal to and describe in a less cryptic way the traditional
|
||||
error code values as offered by bf(C) macros (e.g.,
|
||||
verb(
|
||||
enum class errc
|
||||
{
|
||||
address_family_not_supported, // EAFNOSUPPORT
|
||||
address_in_use, // EADDRINUSE
|
||||
address_not_available, // EADDRNOTAVAIL
|
||||
already_connected, // EISCONN
|
||||
argument_list_too_long, // E2BIG
|
||||
argument_out_of_domain, // EDOM
|
||||
bad_address, // EFAULT
|
||||
...
|
||||
};
|
||||
)
|
||||
|
||||
In addition to the standard tt(what) member, the tt(system_error) class also
|
||||
offers a member tt(code) returning a const reference to the exception's error
|
||||
|
|
Loading…
Reference in a new issue