Constructs an exception object associated with the specified platform-specific error code, a specified function object, mapping the code to the corresponding description, and a user-defined description format.
- Template Parameters
-
CharType | is a type of the description to be set which is either char or wchar_t . |
GetDescriptionFn | is a type of a callabke object that should receive an error code of the platform_code_t type and return a corresponding wide string system message describing the error. The string should be represented either as a raw pointer to a wide C string, as a unique pointer (e.g. [std::unique_ptr], Chusov::String::AutoCString) to the one, or as a C++ [std::basic_string] object. The string is copied to an internal memory buffer which is managed by the exception object. |
DescriptionFormatParams | Deduced types of additional arguments passed to the function to format the message. |
- Parameters
-
[in] | nPlatformCode | is a numeric value of the platform error code to be associated with the created exception. |
[in] | fnGetDescription | is a universal reference to a function object of the GetDescriptionFn type performing the mapping as specified above. |
[in] | pszDescription | is an optional wide-string defining the format of the description to be associated with the error code. At first, the formatting is performed according to the rules defined for the Chusov::String::Printf function. The result of this operation is also processed to replace the tags in angle brackets with the corresponding text, as specified for the PlatformException class template.
If the parameter is NULL or points to an empty string, the generated description is of the "Underlying platform error \<PLATFORM_CODE\> ("<PLATFORM_DESCRIPTION>")" format. |
[in] | formatting_params | specifies a set of additional parameters used during the creation of the description as specified by the pszDescription parameter according to the rules defined for the Chusov::String::Printf function. If pszDescription is NULL or points to an empty string, the parameters are ignored. |
In the description string the following tags are allowed:
Tag | Replacement |
<CODE> | A numeric value of the CHSVERROR_PLATFORM_ERROR chsvlib error code. |
<DESCRIPTION> | A string specifying the description for the CHSVERROR_PLATFORM_ERROR chsvlib error code. |
<PLATFORM_CODE> | A wide string representation of the platform specific error code. |
<PLATFORM_DESCRIPTION> | A description for the given platform-specific error code. This one is returned by the fnGetDescription functor. |
1 Defined by the ExceptionWithGenericCode class template.