Start with the user docs in docs/rich_error_code.md.
Declared in <folly/result/coded_rich_error.h>
template<typename... Codes>
class coded_rich_error
: public rich_error_base
Error type for storing 1 or more application-specific error codes. Loosely parallel to std::system_error -- though, if you actually have an OS error, please read errc_rich_error.h next.
Compared to system_error, this has all the advantages of rich errors -- RTTI-free access on the happy path, automatic source location capture, cheaper message support, fmt and << support, etc.
If you specifically need an analog of std::nested_exception, where the new error shadows the old (partly or completely), then check out the two templates in nestable_coded_rich_error.h.
| Name | Description |
|---|---|
rich_error_base | Base class for exceptions that carry a queryable rich error code. |
| Name | Description |
|---|---|
fmt_all_codes_t | A fmt-formattable view of all codes in this error's hierarchy. |
underlying_error_private_t | Passkey granting folly-internal access to the underlying-error pointer. |
| Name | Description |
|---|---|
folly_get_exception_hint_types | Fast exception-lookup hints for this error type. |
folly_rich_error_codes_t | get_rich_error_code protocol support. |
| Name | Description |
|---|---|
coded_rich_error [constructor] | Constructs from the codes and an optional message. |
all_codes_for_fmt | Returns a fmt-formattable view of all codes in this error's hierarchy. |
code | Easy code access for the common case of "just one code". |
code_of_type | This will rarely be used by end-users, since get_rich_error_code is the canonical accessor for codes. |
format_to [virtual] | Renders this error for fmt and ostream<<. |
format_with_epitaphs | Formats this epitaph stack, starting with its underlying error. |
format_with_epitaphs_without_first_underlying | Formats only the epitaph stack, omitting the first underlying error. |
mutable_underlying_error | Returns mutable access to the underlying error pointer (folly-internal). |
next_error_for_epitaph [virtual] | Returns the next error in the epitaph/nesting chain, if any. |
partial_message [virtual] | Returns the partial message for this error. |
retrieve_code | retrieve_code overloads |
source_location [virtual] | Returns the source location captured for this error. |
underlying_error | Returns the error that is actually propagating (the "underlying" error). |
| Name | Description |
|---|---|
make | See make_coded_rich_error(), which deduces the code types. This is useful as errc_rich_error::make, and in similar contexts. |
| Name | Description |
|---|---|
operator= | Assignment operators |
set_underlying_error | Sets the underlying error pointer (only used by epitaph_non_value). |