Edit

Share via


error_category Class

Represents the abstract, common base for objects that describes a category of error codes.

Syntax

class error_category;

constexpr error_category() noexcept;
virtual ~error_category();
error_category(const error_category&) = delete

Remarks

Two predefined objects implement error_category: generic_category and system_category.

Members

Typedefs

Name Description
value_type A type that represents the stored error code value.

Functions

Name Description
default_error_condition Stores the error code value for an error condition object.
equivalent Returns a value that specifies whether error objects are equivalent.
generic_category
message Returns the name of the specified error code.
name Returns the name of the category.
system_category

Operators

Name Description
operator= Assignment operator.
operator== Tests for equality between error_category objects.
operator!= Tests for inequality between error_category objects.
operator< Tests if the error_category object is less than the error_category object passed in for comparison.

default_error_condition

Stores the error code value for an error condition object.

virtual error_condition default_error_condition(int _Errval) const;

Parameters

_Errval
The error code value to store in the error_condition.

Return Value

Returns error_condition(_Errval, *this).

Remarks

equivalent

Returns a value that specifies whether error objects are equivalent.

virtual bool equivalent(value_type _Errval,
    const error_condition& _Cond) const;

virtual bool equivalent(const error_code& _Code,
    value_type _Errval) const;

Parameters

_Errval
The error code value to compare.

_Cond
The error_condition object to compare.

_Code
The error_code object to compare.

Return Value

true if the category and value are equal; otherwise, false.

Remarks

The first member function returns *this == _Cond.category() && _Cond.value() == _Errval.

The second member function returns *this == _Code.category() && _Code.value() == _Errval.

generic_category

const error_category& generic_category();

message

Returns the name of the specified error code.

virtual string message(error_code::value_type val) const = 0;

Parameters

val
The error code value to describe.

Return Value

Returns a descriptive name of the error code val for the category. If the error code is unrecognized, returns "unknown error".

Remarks

name

Returns the name of the category.

virtual const char *name() const = 0;

Return Value

Returns the name of the category as a null-terminated byte string.

operator=

error_category& operator=(const error_category&) = delete;

operator==

Tests for equality between error_category objects.

bool operator==(const error_category& right) const;

Parameters

right
The object to be tested for equality.

Return Value

true if the objects are equal; false if the objects aren't equal.

Remarks

This member operator returns this == &right.

operator!=

Tests for inequality between error_category objects.

bool operator!=(const error_category& right) const;

Parameters

right
The object to be tested for inequality.

Return Value

true if the error_category object isn't equal to the error_category object passed in right; otherwise false.

Remarks

The member operator returns (!*this == right).

operator<

Tests if the error_category object is less than the error_category object passed in for comparison.

bool operator<(const error_category& right) const;

Parameters

right
The error_category object to be compared.

Return Value

true if the error_category object is less than the error_category object passed in for comparison; Otherwise, false.

Remarks

The member operator returns this < &right.

system_category

const error_category& system_category();

value_type

A type that represents the stored error code value.

typedef int value_type;

Remarks

This type definition is a synonym for int.