chsvlib
chsv helper source code

◆ SetCodeAndDescription() [3/8]

auto SetCodeAndDescription ( code_t  nCode,
Exception::vararg_tag_t  ,
const char_t *restrict  lpszDescriptionFormat,
std::va_list  ap 
) -> std::enable_if_t<std::is_integral<char_t>::value>
protectednoexcept

Sets a new exception description, according to the specified error code, formatting rules (without tag customization), variadic list of parameters and a function object mapping the error code to its default string description.

Template Parameters
char_tis a type of the description to be set which is either char or wchar_t.
Parameters
[in]nCodeis a numeric value of the error code.
[in]lpszDescriptionFormatis an optional pointer to a string specifying a format of the constructed description. See details.
[in]apis a list of additional parameters to be used during the construction of the description as specified for the Chusov::String::Printf <char_t> function. If lpszDescriptionFormat is NULL the parameter list is ignored.

The function performs formatting of the output string using control character sequences and arguments of the argument list ap as specified for the Chusov::String::Printf <char_t> function. The result is then analyzed for presence of the tags "\<CODE\>" and "\<DESCRIPTION\>". The former is replaced with a hexadecimal representation of the error code nCode. If the "\<DESCRIPTION\>" tag is encountered in the string, it is replaced with a message saying that the description is unspecified. To specify the description use one of the other overloads of SetCodeAndDescription.

After these two transformations, the resulting string becomes a message associated with the exception object and obtained using Exception::what or Exception::What.