chsvlib
chsv helper source code

◆ ChsvExceptionByPlatformCode() [1/4]

void Chusov::Exceptions::ChsvExceptionByPlatformCode ( )

Creates an instance of the ChsvCodeExceptionTempl class and throws it as an exception. The instantiation of the ChsvCodeExceptionTempl class template is chosen depending on the result of a translation of the operating system error code specified by GetLastSystemError.

Template Parameters
fProcessSuccessCodeAsUnknownErroris a flag specifying if a zero operating system error code should be interpreted as an unknown error. This means that if the flag is set, and the error code has a zero value, then the thrown exception is UnknownException. Otherwise, it is ChsvCodeExceptionTempl<CHSVERROR_SUCCESS>.

The function generates an exception of a type implemented by either an instantiation of the ChsvCodeExceptionTempl class template or by an instantiation of the PlatformException class template, which directly inherits the ChsvCodeExceptionTempl<CHSVERROR_PLATFORM_ERROR> class. The specific class is determined based on the value of GetLastSystemError, or, more specifically, on a result of mapping its value to the corresponding chsvlib error code, which is performed by the Chusov::SystemErrorToChsvError function. The latter returns CHSVERROR_PLATFORM_ERROR, if the accordance between the operating system error code and a chsvlib error code is not known. In this case the corresponding exception to be thrown is an instance of the PlatformException class.

If the mapping to a specific chsvlib error code, which is not CHSVERROR_PLATFORM_ERROR, was performed, the function generates exception of type, which is one of the predefined exceptions, which are instances of the ChsvCodeExceptionTempl class template for each specific error code. Such exception will have the default description.

If the mapping to a specific chsvlib error code cannot be performed, the generated exception is of type described by an instantiation of the PlatformException class template with chsv_syserror_t type passed as a template parameter. The description of such an exception, which can later be retrieved by the caller invoking the what or What methods, is:

operating system error <PLATFORM_CODE> ("<PLATFORM_DESCRIPTION>")

where <PLATFORM_CODE> and <PLATFORM_DESCRIPTION> are tags replaced by a numeric value of the operating system error and its description, retrieved by an internal call to the operating system.