9 Error reporting [err.report]

9.3 Error conditions [err.report.conditions]

Unless otherwise specified, when the behavior of a synchronous or asynchronous operation is defined “as if” implemented by a POSIX function, the error_code produced by the function shall meet the following requirements:

  • If the failure condition is one that is listed by POSIX for that function, the error_code shall compare equal to the error's corresponding enum class errc (C++ 2014 [syserr]) or enum class resolver_errc ([internet.resolver.err]) constant.

  • Otherwise, the error_code shall be set to an implementation-defined value that reflects the underlying operating system error.

Example: The POSIX specification for shutdown lists EBADF as one of its possible errors. If a function that is specified “as if” implemented by shutdown fails with EBADF then the following condition holds for the error_code value ec: ec == errc::bad_file_descriptor  — end example ]

When the description of a function contains the element Error conditions, this lists conditions where the operation may fail. The conditions are listed, together with a suitable explanation, as enum class constants. Unless otherwise specified, this list is a subset of the failure conditions associated with the function.