A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/system_error/error_condition/category/ below:

public member function

<system_error>

std::error_condition::category
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
21
// error_condition observers: value, category and message
#include <iostream>       // std::cout, std::ios
#include <system_error>   // std::system_error, std::error_condition
#include <fstream>        // std::ifstream
#include <string>         // std::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):\n";
    std::cout << "Value: " << cond.value() << '\n';
    std::cout << "Category: " << cond.category().name() << '\n';
    std::cout << "Message: " << cond.message() << '\n';
  }
  return 0;
}

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


See also
error_condition::value
Error condition value (public member function)
error_condition::message
Get message (public member function)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4