Does C++ have predefined text constants / string constant to be used as replacements for digits when testing errorcodes ?

An example:

if (errcode == 17){
  std::cout << "The file already exists!" << std::endl;
  }

To make it more readable I can write:

 if (errcode == FILE_ALREADY_EXISTS){
   std::cout << "File already exists!" << std::endl;
   }

Of course I can define an integer constant with the name FILE_ALREADY_EXISTS and give it the value 17,
but (maybe) there are some predefined string constants / text constants defined in a standard header-file somewhere ?

<cerrno> defines several standard integer error codes (integer constant expressions with type int).
For instance, ENOENT for 'No such file or directory'
http://en.cppreference.com/w/cpp/error/errno_macros

<system_error> gives us the scoped enum std::errc
For instance, std::errc::no_such_file_or_directory
http://en.cppreference.com/w/cpp/error/errc

<system_error> also has the class std::error_code. Objects of this type can be created from an error code enum and std::error_code::::message() returns a string containing the error message.
http://en.cppreference.com/w/cpp/error/error_code/message

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.