public member function

std::error_condition::category

<system_error>
const error_category& category() const noexcept;
Get category
Returns a reference to the error category associated with the error_condition object.

Parameters

none

Return value

A reference to a non-copyable object of a type derived from error_category.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// error_condition observers: value, category and message
#include <iostream>
#include <system_error>
#include <fstream>
#include <string>

int main()
{
  std::ifstream is;
  is.exceptions (std::ios::failbit);
  try {
    is.open ("unexistent.txt");
  } catch (std::system_error excptn) {
    std::error_condition cond = excptn.code().default_error_condition();
    std::cout << "Exception caught (system_error): " << std::endl;
    std::cout << "Value: " << cond.value() << std::endl;
    std::cout << "Category: " << cond.category().name() << std::endl;
    std::cout << "Message: " << cond.message() << std::endl;
  }
}


Possible output:
Exception caught (system_error):
Value: 1
Category: iostream
Message: iostream stream error

See also