Sets a new exception description, according to the specified error code, formatting rules and a functor object mapping the error code to its default string description. .
- Template Parameters
-
char_t | is a type of the description to be set which is either char or wchar_t . |
fn_t | is a type of the function object. A class defining the type must specify public operator() that receives a numeric value of an error code and returns its description which is either a C pointer or an std::unique_ptr pointer to a multibyte or wide C string or and std::basic_string object specialized for char or wchar_t elements and for any CharTraits and Allocator. On failure within the operator the latter may return a NULL, default constructed std::unique_ptr or default constructed std::basic_string object, depending on the return value of the parenthesis operator. In case of the failure the description is constructed from the string saying that the description is not specified. |
- Parameters
-
[in] | nCode | is a numeric value of the error code. |
[in] | GetDescription | is a universal reference to a function object of the fn_t type. It should map the error code to the corresponding string description. The class of the functor must define a parenthesis operator (operator()), which receives an error code as its only parameter and returns a corresponding string. The string can be represented as a C string, either multibyte or wide, as a unique pointer (see std::unique_ptr) to a multibyte or wide string, or as a std::basic_string object specialized for char or wchar_t character type (for multibyte and wide strings respectively) as well as any CharTraits and Allocator. Note, that every type of the strings returned by the operator is considered non-modifiable, so that C strings are not automatically deallocated. On failure the function may return default values of the respected types, that are NULL pointers for C strings, default-constructed std::unique_ptr or default-constructed std::basic_string. |
[in] | pTags | is an optional pointer to a vector of Chusov::String::TAG_DESCRIPTION_PARAM_W objects specifying additional tags for the formatted description as specified for the Chusov::String::AllocateAndFormatStringByTagsIndirectW function. The predefined tags are <CODE> and <DESCRIPTION>. If either of these predefined tags are specified by the parameter, the user-defined variants are ignored by the function. See the details. |
| cTags | is a number of elements specified by the pTags vector. If the latter is NULL, the cTags parameter is ignored. |
[in] | lpszDescriptionFormat | is an optional pointer to a string specifying a format of the constructed description. See details. |
The function performs formatting by tags in angle brackets as specified by the Chusov::String::AllocateAndFormatStringByTagsIndirectW function. There are two predefined tags - <CODE> and <DESCRIPTION> that are always changed to a numeric (hexadecimal) value of an error code and to its description, returned by the functor, respectively. This behaviour cannot be changed by a caller. Other tags may or may not be specified by the pTags pointer to a vector of cTags size.
After these two transformations, the resulting string becomes a message associated with the exception object and obtained using Exception::what or Exception::What.