chsvlib
chsv helper source code

◆ SetCodeAndDescription() [2/8]

auto SetCodeAndDescription ( code_t  nCode,
const char_t *restrict  lpszDescriptionFormat,
DescriptionFormatParams ...  formatting_params 
) -> std::enable_if_t<Chusov::String::is_valid_printf_type_set_v<DescriptionFormatParams...>>
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.
DescriptionFormatParamsDeduced types of additional arguments passed to the function to format the message.
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.
[in]formatting_paramsAdditional 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 formatting_params pack 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.