<system_error>[added with C++11]
errc
· error_code
· error_category
· error_condition
· hash
· generic_category
· generic_errno
· is_error_code_enum
· is_error_condition_enum
· make_error_code
· make_error_condition
· system_category
· system_error
address_family_not_supported
· address_in_use
· address_not_available
· already_connected
· argument_list_too_long
· argument_out_of_domain
· bad_address
· bad_file_descriptor
· bad_message
· broken_pipe
· connection_aborted
· connection_already_in_progress
· connection_refused
· connection_reset
· cross_device_link
· destination_address_required
· device_or_resource_busy
· directory_not_empty
· executable_format_error
· file_exists
· file_too_large
· filename_too_long
· function_not_supported
· host_unreachable
· identifier_removed
· illegal_byte_sequence
· inappropriate_io_control_operation
· interrupted
· invalid_argument
· invalid_seek
· io_error
· is_a_directory
· message_size
· network_down
· network_reset
· network_unreachable
· no_buffer_space
· no_child_process
· no_link
· no_lock_available
· no_message_available
· no_message
· no_protocol_option
· no_space_on_device
· no_stream_resources
· no_such_device_or_address
· no_such_device
· no_such_file_or_directory
· no_such_process
· not_a_directory
· not_a_socket
· not_a_stream
· not_connected
· not_enough_memory
· not_supported
· operation_canceled
· operation_in_progress
· operation_not_permitted
· operation_not_supported
· operation_would_block
· owner_dead
· permission_denied
· protocol_error
· protocol_not_supported
· read_only_file_system
· resource_deadlock_would_occur
· resource_unavailable_try_again
· result_out_of_range
· state_not_recoverable
· stream_timeout
· text_file_busy
· timed_out
· too_many_files_open_in_system
· too_many_files_open
· too_many_links
· too_many_synbolic_link_levels
· value_too_large
· wrong_protocol_type
Include the header <system_error> to define
the exception class system_error and related templates
for processing low-level system errors.
namespace std {
// TYPES
enum class errc;
typedef errc generic_errno;
class error_code;
class error_condition;
class error_category;
class system_error;
template<Enum>
class is_error_code_enum;
template<Enum>
class is_error_condition_enum;
template<>
struct hash<error_code>
: public unary_function<bitset<Bits>, size_t> {
size_t operator()(error_code val) const;
};
// FUNCTIONS
const error_category& generic_category() noexcept;
const error_category& system_category() noexcept;
bool operator==(const error_code& left, const error_condition& right) noexcept;
bool operator==(const error_condition& left, const error_code& right) noexcept;
bool operator!=(const error_code& left, const error_condition& right) noexcept;
bool operator!=(const error_condition& left, const error_code& right) noexcept;
error_code make_error_code(generic_errno errval) noexcept;
error_code make_error_condition(generic_errno errval) noexcept;
template<class Elem,
class Traits>
basic_ostream<Elem, Traits>&
operator<<(basic_ostream<Elem, Traits>& ostr,
const error_code& code);
} // namespace std
errcenum 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,
bad_file_descriptor = EBADF,
bad_message = EBADMSG,
broken_pipe = EPIPE,
connection_aborted = ECONNABORTED,
connection_already_in_progress = EALREADY,
connection_refused = ECONNREFUSED,
connection_reset = ECONNRESET,
cross_device_link = EXDEV,
destination_address_required = EDESTADDRREQ,
device_or_resource_busy = EBUSY,
directory_not_empty = ENOTEMPTY,
executable_format_error = ENOEXEC,
file_exists = EEXIST,
file_too_large = EFBIG,
filename_too_long = ENAMETOOLONG,
function_not_supported = ENOSYS,
host_unreachable = EHOSTUNREACH,
identifier_removed = EIDRM,
illegal_byte_sequence = EILSEQ,
inappropriate_io_control_operation = ENOTTY,
interrupted = EINTR,
invalid_argument = EINVAL,
invalid_seek = ESPIPE,
io_error = EIO,
is_a_directory = EISDIR,
message_size = EMSGSIZE,
network_down = ENETDOWN,
network_reset = ENETRESET,
network_unreachable = ENETUNREACH,
no_buffer_space = ENOBUFS,
no_child_process = ECHILD,
no_link = ENOLINK,
no_lock_available = ENOLCK,
no_message_available = ENODATA,
no_message = ENOMSG,
no_protocol_option = ENOPROTOOPT,
no_space_on_device = ENOSPC,
no_stream_resources = ENOSR,
no_such_device_or_address = ENXIO,
no_such_device = ENODEV,
no_such_file_or_directory = ENOENT,
no_such_process = ESRCH,
not_a_directory = ENOTDIR,
not_a_socket = ENOTSOCK,
not_a_stream = ENOSTR,
not_connected = ENOTCONN,
not_enough_memory = ENOMEM,
not_supported = ENOTSUP,
operation_canceled = ECANCELED,
operation_in_progress = EINPROGRESS,
operation_not_permitted = EPERM,
operation_not_supported = EOPNOTSUPP,
operation_would_block = EWOULDBLOCK,
owner_dead = EOWNERDEAD,
permission_denied = EACCES,
protocol_error = EPROTO,
protocol_not_supported = EPROTONOSUPPORT,
read_only_file_system = EROFS,
resource_deadlock_would_occur = EDEADLK,
resource_unavailable_try_again = EAGAIN,
result_out_of_range = ERANGE,
state_not_recoverable = ENOTRECOVERABLE,
stream_timeout = ETIME,
text_file_busy = ETXTBSY,
timed_out = ETIMEDOUT,
too_many_files_open_in_system = ENFILE,
too_many_files_open = EMFILE,
too_many_links = EMLINK,
too_many_synbolic_link_levels = ELOOP,
value_too_large = EOVERFLOW,
wrong_protocol_type = EPROTOTYPE,
};
The scoped enumeration supplies symbolic names for all the error-code
macros defined by Posix in <errno.h>.
error_categoryclass error_category {
public:
error_category();
virtual ~error_category() noexcept;
virtual const char *name() const noexcept = 0;
virtual string message(int val) const = 0;
virtual error_condition
default_error_condition(int errval) const noexcept;
virtual bool equivalent(int errval,
const error_condition& code) const noexcept;
virtual bool equivalent(const error_code& code,
int errval) const noexcept;
bool operator==(const error_category& right) const noexcept;
bool operator!=(const error_category& right) const noexcept;
bool operator<(const error_category& right) const noexcept;
error_category(const error_category&) = delete;
error_category& operator=(const error_category&) = delete;
};
The abstract class is the common base for objects that characterize a category of error codes. Two such objects are predefined, one for the generic category and one for the system category.
error_category::default_error_conditionvirtual error_condition
default_error_condition(int errval) const noexcept;
The member function returns
error_condition(errval, *this).
For the system category class,
if errval corresponds to a Posix code,
the function returns
error_condition(errval,
generic_category()).
Otherwise, it returns
error_condition(errval,
system_category()).
error_category::equivalentvirtual bool equivalent(int errval,
const error_condition& code) const noexcept;
virtual bool equivalent(const error_code& code,
int errval) const noexcept;
The member function returns
*this == code.category() && code.value() == errval.
error_category::messagevirtual string message(int val) const = 0;
The virtual function returns a description of the error code
val for the category.
error_category::namevirtual const char *name() const noexcept = 0;
The virtual function returns the name of the category as an NTBS.
For the generic category class,
the function returns a pointer to the NTBS "generic".
For the system category class,
the function returns a pointer to the NTBS "system".
error_category::operator==bool operator==(const error_category& right) const noexcept;
The member operator returns this == &right.
error_category::operator!=bool operator!=(const error_category& right) const noexcept;
The member operator returns (!*this == right).
error_category::operator<bool operator<(const error_category& right) const noexcept;
The member operator returns this < &right.
error_codeclass error_code {
public:
error_code() noexcept;
error_code(int val, const error_category& cat) noexcept;
template<class Enum>
error_code(Enum error) noexcept;
void assign(int val, const error_category& cat) noexcept;
template<class Enum>
error_code& operator=(Enum error) noexcept;
void clear() noexcept;
int value() const noexcept;
const error_category& category() const noexcept;
error_condition default_error_condition() const noexcept;
string message() const;
explicit operator bool() const noexcept;
bool operator==(const error_code& right) const noexcept;
bool operator!=(const error_code& right) const noexcept;
bool operator<(const error_code& right) const noexcept;
};
The class stores an error code value and a pointer to an object that characterizes a category of error codes to characterize a reported low-level system error.
error_code::assignvoid assign(int val, const error_category& cat) noexcept;
The member function stores val as the error code value
and a pointer to cat.
error_code::categoryconst error_category& category() const noexcept;
The member function returns a reference to the stored category.
error_code::clearclear() noexcept;
The member function stores a zero error code value and a pointer to the
system category.
error_code::default_error_conditionerror_condition default_error_condition() const noexcept;
The member function returns
category().
default_error_condition(
value()).
error_code::error_codeerror_code() noexcept;
error_code(int val, const error_category& cat) noexcept;
template<class Enum>
error_code(Enum error) noexcept;
The first constructor stores a zero error code value and a pointer to the
system category.
The second constructor stores val as the error code value
and a pointer to cat.
The third constructor assigns
make_error_code(error)
to *this.
Unless is_error_code_enum<Enum>
holds true,
the constructor does not participate in overload resolution.
error_code::messagestring message() const noexcept;
The member function returns
category().
message(
value()).
error_code::operator boolexplicit operator bool() const noexcept;
The operator returns a value convertible to true only if
value() != 0.
The return type is convertible only to bool,
not to void * or other known scalar type.
error_code::operator=template<class Enum>
error_code& operator=(Enum error) noexcept;
The member operator assigns
make_error_code(error)
to *this.
It returns *this.
Unless is_error_code_enum<Enum>
holds true,
the operator does not participate in overload resolution.
error_code::operator==bool operator==(const error_code& right) const noexcept;
The member operator returns category() == right.category()
&& value == right.value().
error_code::operator!=bool operator!=(const error_code& right) const noexcept;
The member operator returns !(*this == right).
error_code::operator<bool operator<(const error_code& right) const noexcept;
The member operator returns category() < right.category()
|| category() == right.category()
&& value < right.value().
error_code::valueint value() const noexcept;
The member function returns the stored error code value.
error_conditionclass error_condition {
public:
error_condition() noexcept;
error_condition(int val, const error_category& cat) noexcept;
template<class Enum>
error_condition(Enum error) noexcept;
void assign(int val, const error_category& cat) noexcept;
template<class Enum>
error_condition> operator=(Enum error) noexcept;
void clear();
int value() const noexcept;
const error_category& category() const noexcept;
string message() const;
explicit operator bool() const noexcept;
bool operator==(const error_condition& right) const noexcept;
bool operator!=(const error_condition& right) const noexcept;
bool operator<(const error_condition& right) const noexcept;
};
The class stores an error code value and a pointer to an object that characterizes a category of error codes to characterize a reported user-defined error.
error_condition::assignvoid assign(int val, const error_category& cat) noexcept;
The member function stores val as the error code value
and a pointer to cat.
error_condition::categoryconst error_category& category() const noexcept;
The member function returns a reference to the stored category.
error_condition::clearclear() noexcept;
The member function stores a zero error code value and a pointer to the
generic category.
error_condition::error_conditionerror_condition() noexcept;
error_condition(int val, const error_category& cat) noexcept;
template<class Enum>
error_condition(Enum error) noexcept;
The first constructor stores a zero error code value and a pointer to the
generic category.
The second constructor stores val as the error code value
and a pointer to error_category.
The third constructor assigns
make_error_code(error)
to *this.
Unless is_error_condition_enum<Enum>
holds true,
the constructor does not participate in overload resolution.
error_condition::messagestring message() const;
The member function returns
category().
message(
value()).
error_condition::operator boolexplicit operator bool() const noexcept;
The operator returns a value convertible to true only if
value() != 0.
The return type is convertible only to bool,
not to void * or other known scalar type.
error_condition::operator=template<class Enum>
error_condition>::type& operator=(Enum error) noexcept;
The member operator assigns
make_error_code(error)
to *this.
It returns *this.
Unless is_error_condition_enum<Enum>
holds true,
the operator does not participate in overload resolution.
error_condition::operator==bool operator==(const error_condition& right) const noexcept;
The member operator returns category() == right.category()
&& value == right.value().
error_condition::operator!=bool operator!=(const error_condition& right) const noexcept;
The member operator returns !(*this == right).
error_condition::operator<bool operator<(const error_condition& right) const noexcept;
The member operator returns category() < right.category()
|| category() == right.category()
&& value < right.value().
error_condition::valueint value() const noexcept;
The member function returns the stored error code value.
generic_categoryconst error_category& generic_category() noexcept;
The function returns a reference to the
generic category.
generic_errnotypedef errc generic_error;
The type is a synonym for
errc.
hashtemplate<>
struct hash<error_code>
: public unary_function<bitset<Bits>, size_t> {
size_t operator()(error_code val) const;
};
The template class defines its member function as returning
a value uniquely determined by val. The member function defines a
hash function, suitable for mapping values of type
error_code
to a distribution of index values.
is_error_code_enumtemplate<Enum>
class is_error_code_enum;
An instance of the type predicate
holds true if the type Enum is
an enumeration suitable for storing in an object of type
error_code.
It is permissible to add specializations to this type for user-defined types.
is_error_condition_enumtemplate<Enum>
class is_error_condition_enum;
An instance of the type predicate
holds true if the type Enum is
an enumeration suitable for storing in an object of type
error_condition.
It is permissible to add specializations to this type for user-defined types.
make_error_codeerror_code make_error_code(generic_errno errval) noexcept;
The function returns
error_code(errval,
generic_category()).
It is permissible to add specializations to this function for user-defined types.
make_error_conditionerror_condition make_error_condition(generic_errno errval) noexcept;
The function returns
error_condition(errval,
generic_category()).
operator<<template<class Elem,
class Traits>
basic_ostream<Elem, Traits>&
operator<<(basic_ostream<Elem, Traits>& ostr,
const error_code& code);
The template function returns
ostr << code.category() << ':' << code.value().
operator==bool operator==(const error_code& left, const error_condition& right) noexcept; bool operator==(const error_condition& left, const error_code& right) noexcept;
The function returns left.category().equivalent(left.value(), right)
|| right.category().equivalent(left, right.value()).
operator!=bool operator!=(const error_code& left, const error_condition& right); bool operator!=(const error_condition& left, const error_code& right);
The function returns !(left == right).
system_categoryconst error_category& system_category() noexcept;
The function returns a reference to the
system category.
system_errorclass system_error : public runtime_error {
public:
explicit system_error(error_code code, const string& message = "");
system_error(error_code code, const char *message);
system_error(int val, const error_category& cat,
const string& message);
system_error(int val, const error_category& cat,
const char *message);
const error_code& code() const throw();
};
The class serves as the base class for all exceptions thrown
to report a low-level system overflow. The value returned by
what() is constructed from
message and the stored object of type
error_code
(either code or error_code(val, cat)).
The member function code() returns the stored error_code
object.
See also the Table of Contents and the Index.
Copyright © 1992-2013 by Dinkumware, Ltd. All rights reserved.