chsvlib
chsv helper source code

◆ ExceptionWithGenericCode() [4/10]

ExceptionWithGenericCode ( code_t  nCode,
const char_t *restrict  lpszDescriptionFormat,
DescriptionFormatParams ...  formatting_params 
)
noexcept

Constructs an exception object with a specified error code, a format string and parameters for the formatting as specified by the Chusov::String::Printf function. .

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 code to be associated with the constructed exception object.
[in]lpszDescriptionFormatis an optional pointer to a string specifying a format of the constructed description. See the details.
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 additional parameters are ignored.

The constructor creates an instance of the ExceptionWithGenericCode<code_t> class with associated error code and the description. The description is constructed as specified by the format string using control character sequences, as specified for the Chusov::String::Printf <char_t> function. The result of this formatting is analyzed for presence of the <CODE> and <DESCRIPTION> tags which are replaced by a string representation of an error code and by the corresponding description respectively. Because the latter is not specified, the corresponding description states that fact. To specify a function objects which maps the error code use the ExceptionWithGenericCode(code_t nCode, fn_t&& GetDescription, const wchar_t* RESTRICT lpszDescriptionFormat, DescriptionFormatParams... formatting_params) constructor.

Remarks
The function is provided only for compilers with expression SFINAE support. For older compilers use an overload which takes nullptr in the place of the omitted functor.
See also
ExceptionWithGenericCode(code_t nCode, fn_t&& GetDescription, const char_t* restrict lpszDescriptionFormat, DescriptionFormatParams... formatting_params);
ExceptionWithGenericCode(code_t nCode, fn_t&& GetDescription, Exception::vararg_tag_t, _In_opt_z_ const char_t* RESTRICT lpszDescriptionFormat, std::va_list ap);
ExceptionWithGenericCode(code_t nCode, Exception::vararg_tag_t, _In_opt_z_ const char_t* RESTRICT lpszDescriptionFormat, std::va_list ap);
ExceptionWithGenericCode(code_t nCode, std::nullptr_t, _In_opt_z_ const char_t* RESTRICT lpszDescriptionFormat, DescriptionFormatParams... formatting_params).