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_code/message/ below:

public member function

<system_error>

std::error_code::message

Get message

Returns the message associated with the error code.

Error messages are defined by the category the error code belongs to.

This function returns the same as if the following member was called:


1
category().message(value())

Parameters none

Return value A string object with the message associated with the error code.

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

int main()
{
  std::ifstream is;
  is.exceptions (std::ios::failbit);
  try {
    is.open ("unexistent.txt");
  } catch (const std::system_error& e) {
    std::cout << "Exception caught (system_error):\n";
    std::cout << "Error: " << e.what() << '\n';
    std::cout << "Code: " << e.code().value() << '\n';
    std::cout << "Category: " << e.code().category().name() << '\n';
    std::cout << "Message: " << e.code().message() << '\n';
  }
  return 0;
}

Possible output:
Exception caught (system_error):
Error: ios_base::failbit set
Code: 1
Category: iostream
Message: iostream stream error


See also
error_code::value
Error value (public member function)
error_code::category
Get category (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