void Chusov::Exceptions::ChsvExceptionByPosixCode | ( | ) |
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 POSIX error code specified by errno.
fProcessSuccessCodeAsUnknownError | is a flag specifying if a zero POSIX 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 errno, or, more specifically, on a result of mapping its value to the corresponding chsvlib error code, which is performed by the PosixErrorToChsvError function. The latter returns CHSVERROR_PLATFORM_ERROR
, if the accordance between the POSIX 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 errno_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:
POSIX error <PLATFORM_CODE> ("<PLATFORM_DESCRIPTION>")
where <PLATFORM_CODE> and <PLATFORM_DESCRIPTION> are tags replaced by a numeric value of the POSIX error and its description, retrieved by an internal call to the strerror function.