chsvlib
chsv helper source code

◆ PlatformException() [2/9]

PlatformException ( platform_code_t  nPlatformCode,
GetDescriptionFn &&  fnGetDescription 
)
noexcept

Constructs an exception object bound with the specified platform-specific error code and with the corresponding function object mapping the code to its textual description.

Template Parameters
GetDescriptionFnis a type of the function object mapping the platform-specific error code with the corresponding textual description. If the mapping does not exist, or if any error occurs, the function object may return NULL causing the PlatformException class template instantiation to generate the default unspecified description saying that the description is not specified. Otherwise, the string, returned by the function object's parenthesis operator, must be allocated by one of the functions defined in the Chusov::Memory namespace. The class instantiation owns the returned string, which is freed internally by a call to the Chusov::String::FreeStringW function.
Parameters
[in]nPlatformCodeis a numeric value of the platform error code to be associated with the created exception.
[in]fnGetDescriptionis a universal reference to a function object of the GetDescriptionFn type performing the mapping as specified above.

The constructor generates the description in the format "Underlying platform error \<PLATFORM_CODE\> (\<PLATFORM_DESCRIPTION\>)", where the "\<PLATFORM_CODE\>" tag is replaced by a wide string representation of the value of the platform error code, and the "\<PLATFORM_DESCRIPTION\>" tag is replaced by the description generated by the function object. See details for the PlatformException class template for further explanation about tags.