chsvlib
chsv helper source code

◆ PlatformException() [7/9]

PlatformException ( platform_code_t  nPlatformCode,
GetDescriptionFn &&  fnGetDescription,
std::basic_string< CharType, traits_t, alloc_t >  strDescription 
)
noexcept

Constructs an exception object from a specified platform-specific error code, an optional user-defined function object calling system functions to map the code to the corresponding textual description, and a formatting string.

Template Parameters
GetDescriptionFnis 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.
CharTypeis a type of a symbol of an std::basic_string object specifying the description.
traits_tis a character traits type, such as std::char_traits template instantiations, used by the strDescription string object.
alloc_tis a type of an allocator, such as std::allocator, used by the strDescription string object.
Parameters
[in]nPlatformCodeis a platform-specific error code bound with the constructed exception object.
[in]fnGetDescriptionis an optional callable object returning a textual dscription of an error from a numeric error code. The string is either a C pointer to a zero terminated wide string, or a unique pointer to the one, or an object of type defined by any well-formed instantiation of the std::basic_string template for wchar_t type of characters. A nullptr value can be passed as a value of the parameter which causes a call to be redirected to another overload of the constructor.
[in]strDescriptionis a C++ std::basic_string wide string object specifying the description. Compared to most other constructors of the class the current one does not perform the Printf formatting. However, the tag formatting will be performed causing the constructor to treat angle brackets specially and particularly replace the <CODE> and <DESCRIPTION> tags of the input with a hexadecimal representation of CHSVERROR_PLATFORM_ERROR and a corresponding description (see error handling for the details). Likewise, the <PLATFORM_CODE> and <PLATFORM_DESCRIPTION> will be replaced by a hexadecimal representation of nPlatformCode and by a string returned by the callable object.