std::error_code(3)
π NAME π
std::error_code β the little value-type bestie that carries an error number and the category that tells you what that number actually means π«Ά
β¨ SYNOPSIS β¨
#include <system_error>
πΈ Public Member Functions πΈ
template<typename _ErrorCodeEnum, typename = _Check<_ErrorCodeEnum>> error_code (_ErrorCodeEnum __e) noexceptβ spin one up from your own user-defined type, by callingmake_error_codeπ«error_code (const error_code &)=defaultβ copy ctor, defaulted, no dramaerror_code (int __v, const error_category &__cat) noexceptβ build it from a raw value plus a categoryvoid assign (int __v, const error_category &__cat) noexceptβ reassign the value and the categoryconst error_category & category () const noexceptβ the error category this error belongs to π·οΈvoid clear () noexceptβ wipe it cleanerror_condition default_error_condition () const noexceptβ anerror_conditionfor this error's category and valuestring message () constβ the category's description of the value πoperator bool () const noexceptβ tests whethervalue()is non-zero (so yes, it's the "do I have a problem" check π)error_code & operator= (const error_code &)=defaultβ assignment, defaultedint value () const noexceptβ the error value itself π’
π¦ Related Symbols π¦
bestie, heads up: these are not member symbols, they just hang out in the same neighborhood π
error_code make_error_code (errc __e) noexcepttemplate<typename _CharT, typename _Traits> basic_ostream< _CharT, _Traits > & operator<< (basic_ostream< _CharT, _Traits > &__os, const error_code &__e)strong_ordering operator<=> (const error_code &__lhs, const error_code &__rhs) noexcept
π Detailed Description π
Class error_code
Okay so this class is a value type that stores an integer error number and a category, and the category is what gives that number meaning. Usually you do this right at the spot where the error actually happens, so you capture the original error value before it gets lost in the sauce π
An error_code object can hold the original error value that some subsystem spat out, together with a category that's relevant to that subsystem. For example: errors from POSIX library functions can be represented by an errno value and the "generic" category, but errors from an HTTP library might be represented by an HTTP response status code (like 404) and a custom category that the library defines. Same energy, different category β¨
Since: C++11 β she's been iconic for a minute π
π Constructor & Destructor Documentation π
template<typename _ErrorCodeEnum, typename = _Check<_ErrorCodeEnum>> std::error_code::error_code (_ErrorCodeEnum __e) [inline], [noexcept]
Initialize with a user-defined type, by calling make_error_code. That's the whole move π«Ά
References make_error_code().
π Member Function Documentation π
const error_category & std::error_code::category () const [inline], [noexcept]
The error category that this error belongs to. It's giving "which flavor of problem is this" π·οΈ
Referenced by message().
error_condition std::error_code::default_error_condition () const [noexcept]
An error_condition for this error's category and value.
string std::error_code::message () const [inline]
The category's description of the value. Basically the category translating the number for you π¬
References category(), std::error_category::message(), message(), and value().
Referenced by message().
std::error_code::operator bool () const [inline], [explicit], [noexcept]
Test whether value() is non-zero. Non-zero means yes there's an error, zero means we're chill πΈ
int std::error_code::value () const [inline], [noexcept]
The error value. The raw number. The receipts π’
Referenced by message().
π Author π
Generated automatically by Doxygen for libstdc++ from the source code.
and that's the whole page bestie π generated by Doxygen for libstdc++, and yes, std::error_code(3) said what it said. no cap, go handle your errors. periodt β¨ππ¦
π¦ where this page comes from
- arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
- fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 44: libstdc++-docs 16.2.1-2.fc44
- fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms