The group provides support of basic error code processing mechanism further denoted as chsvlib error codes. More...
Classes | |
union | CHSV_ERROR_CODE |
Definition of a chsvlib error code as a composition of bit fields. The structure is composed to match The Microsoft's definition of the HRESULT. More... | |
struct | CHSV_ERROR_INFO |
The contents of the chsvlib last error state. More... | |
struct | IErrorInfo |
An interface that must be implemented by any class implementing an object to hold error information processed by the SetLastChsvErrorInformation and GetLastChsvErrorInfo. More... | |
class | chsvlib_general_category_t |
A class of general chsvlib error category, which is introduced to conform std::system_error requirements. More... | |
Macros | |
#define | ChsvCode(sev, fac, speccode) |
A macro generating a chsvlib error code by the specified severity, facility and error code. More... | |
#define | ChsvCode_Severity(nCode) |
Tests if the severity bit of the nCode is set to an error. | |
#define | ChsvCode_Facility(nCode) |
Returns eleven facility bits of the nCode. | |
#define | ChsvCode_Specific(nCode) |
Returns the specific error code of the code nCode. | |
#define | ChsvSucceeded(nCode) |
Tests if the severity bit of the nCode indicates an error. | |
#define | ChsvFailed(nCode) |
Tests if the severity bit of the nCode indicates success. | |
#define | MAKE_CHSV_ERROR(nSpecCode) |
Macro for defining constant integer general chsvlib error codes. More... | |
#define | verify(expression) implementation |
Verifies that a parametrically specified predicate expression is satisfied and calls std::abort, if that is not the case. More... | |
#define | verify_security_constraint(cond) ((cond)?true:(RESOLVE_NAMESPACE(Chusov) apply_security_constraint_verification_proc(__FILE__, __LINE__, __func__), false)) |
Assertion alias used in functions implementing secure C extensions as defined in ISO-IEC TR 24731-1. Such assertions are generated when a caller violates runtime constraints defined in the specification. The macro is given to allow disabling the assertion during debug. If the assertion succeeds, the returned evaluated predicate is true . More... | |
Typedefs | |
typedef std::int32_t | chsverror_t |
A type alias for chsvlib error codes. | |
typedef unsigned long | chsv_syserror_t |
A type alias resolving to a platform-defined integral type of system errors. | |
typedef void(* | security_constraint_violation_procedure) (const char *file, unsigned line, const char *func) |
A type alias for a pointer to a procedure used to react upon a runtime constraint violation as defined in the ISO-IEC TR 24731-1 specification. More... | |
Enumerations | |
enum | OnErrorInfoFailture { ERROR_INFO_INIT_FAILED } |
The constant ERROR_INFO_INIT_FAILED is used as a marker for constructors of the CErrorInfoImpl template class parameter of the SetLastChsvErrorInformation function. More... | |
enum class | chsvlib_error { out_of_memory = (signed int) CHSVERROR_OUTOFMEMORY , invalid_parameter = (signed int) CHSVERROR_INVALID_PARAMETER , insufficient_buffer = (signed int) CHSVERROR_INSUFFICIENT_BUFFER , out_of_range = (signed int) CHSVERROR_OUT_OF_RANGE , initialization_failure = (signed int) CHSVERROR_INITIALIZATION_FAILURE , not_initialized = (signed int) CHSVERROR_NOT_INITIALIZED , already_initialized = (signed int) CHSVERROR_ALREADY_INITIALIZED , invalid_version = (signed int) CHSVERROR_INVALID_VERSION , entity_not_found = (signed int) CHSVERROR_NOT_FOUND , entity_already_exists = (signed int) CHSVERROR_ALREADY_EXISTS , invalid_resource = (signed int) CHSVERROR_INVALID_RESOURCE , access_denied = (signed int) CHSVERROR_ACCESS_DENIED , storage_is_full = (signed int) CHSVERROR_STORAGE_FULL , invalid_char_sequence = (signed int) CHSVERROR_INVALID_CHAR_SEQUENCE , operation_cancelled = (signed int) CHSVERROR_OPERATION_CANCELLED , name_too_long = (signed int) CHSVERROR_NAME_TOO_LONG , deadlock = (signed int) CHSVERROR_DEADLOCK , timeout = (signed int) CHSVERROR_TIMEOUT , owner_dead = (signed int) CHSVERROR_OWNER_IS_DEAD , operation_not_supported = (signed int) CHSVERROR_NOT_SUPPORTED , arithmetic_overflow = (signed int) CHSVERROR_ARITHMETIC_OVERFLOW , stack_overflow = (signed int) CHSVERROR_STACK_OVERFLOW , underlying_platform_error = (signed int) CHSVERROR_PLATFORM_ERROR , program_logic_error = (signed int) CHSVERROR_LOGIC_ERROR } |
A strongly typed enumeration with values equal to existing chsvlib error codes. . More... | |
Functions | |
errno_t | Win32ErrorToPosixError (unsigned long nError) noexcept |
Translates a Windows system error code to a POSIX error code. . More... | |
chsverror_t | Win32ErrorToChsvError (unsigned long nError) noexcept |
Translates a Windows system error code to the corresponding chsvlib error code. More... | |
chsverror_t | PosixErrorToChsvError (errno_t nError) noexcept |
Translates a POSIX error code to the corresponding chsvlib error code. More... | |
chsverror_t | SystemErrorToChsvError (chsv_syserror_t err) |
Delegates a call to a platform-dependent function which translates a system error to a corresponding chsvlib error code in a portable way. More... | |
chsv_syserror_t | GetLastSystemError () |
Returns a platform-specific last-error code, i.e. Windows error on Windows (delegates a call to GetLastError) and POSIX error on Linux (see errno). . More... | |
errno_t | GetLastSystemErrorAsPosixCode () |
Returns a platform-specific last-error code represented in POSIX error code space. More... | |
chsverror_t | CHSV_MAKE_CHSV_ERROR (unsigned short nSpecCode) |
The function creating chsvlib error code from the general facility. More... | |
const wchar_t * | ChsvErrorDescriptionW (chsverror_t nErrorCode, unsigned long nReserved) noexcept |
Returns a wide string description on the specified chsvlib error code. More... | |
const char * | ChsvErrorDescriptionA (chsverror_t nErrorCode, unsigned long nReserved) noexcept |
Returns an multi-byte string description on the specified chsvlib error code. More... | |
template<class char_type > | |
const char_type * | ChsvErrorDescription (chsverror_t nErrorCode, unsigned long nReserved=0) noexcept |
Returns an string description on the specified chsvlib error code. More... | |
void | SetLastChsvError (chsverror_t nError) noexcept |
Sets the specified chsvlib code as a thread specific last error code. More... | |
chsverror_t | GetLastChsvError () noexcept |
Returns the last thread specific chsvlib error code. More... | |
void | SetLastChsvErrorInfo (chsverror_t nError, const void *pExtraInfo, std::size_t cbExtraInfo) noexcept |
Sets the a thread specific last error code along with additional data that is supposed to provide extra information about the error. More... | |
const CHSV_ERROR_INFO * | GetLastChsvErrorInfo () noexcept |
Returns a pointer to the CHSV_ERROR_INFO structure containing definition of the last chsvlib error code. More... | |
void | security_constraint_assertion_proc (const char *file, unsigned line, const char *func) noexcept |
Upon a call, if NDEBUG macro is not defined, prints out a message composed from two strings, and an integer, and calls std::abort. If NDEBUG is defined, the function does nothing. More... | |
void | security_constraint_verification_proc (const char *file, unsigned line, const char *func) noexcept |
Upon a call prints out a message composed from two strings, and an integer, and calls std::abort. More... | |
security_constraint_violation_procedure | set_thread_security_constraint_violation_procedure (security_constraint_violation_procedure proc) noexcept |
Sets a procedure called when a security violation defined by ISO-IEC TR 24731-1 is detected via verify_security_constraint. More... | |
template<class CErrorInfoImpl > | |
void | SetLastChsvErrorInformation (unsigned long nError, const CErrorInfoImpl &refErrorInfo) noexcept |
The function setting the last chsvlib error code and its description. More... | |
template<class CErrorInfoImpl > | |
CErrorInfoImpl | GetLastChsvErrorInformation () |
Returns the last extra error description as specified by a call to SetLastChsvErrorInfo(unsigned long nError, const CErrorInfoImpl& refErrorInfo) NOTHROW. More... | |
void | SetLastChsvErrorWC (chsverror_t nChsvError) noexcept |
Sets last chsvlib error code together with win32 error code and C error code. The last two codes are set to ERROR_SUCCESS and 0 respectively. More... | |
void | SetLastChsvErrorInfoWC (chsverror_t nChsvError, unsigned long nWin32Error, errno_t nCError) noexcept |
Sets last chsvlib error code together with win32 error code and C error code. More... | |
unsigned long | GetLastChsvErrorWin32 () noexcept |
Returns last Windows error code. More... | |
errno_t | GetLastChsvErrorC () noexcept |
Returns last C error code. More... | |
const std::error_category & | chsvlib_general_category () noexcept |
Returns a reference to a general error category to generate std::system_error exceptions based on chsvlib error codes. | |
std::error_condition | make_error_condition (chsvlib_error err) |
Creates and returns a new std::error_condition based on a value of chsvlib_error enumeration type. . More... | |
std::error_code | make_error_code (chsvlib_error err) |
Creates and returns an error code object in the form of the standard std::error_code class based on the specified value of the chsvlib_error enumeration type. . More... | |
HRESULT | Win32DlgErrorToWin32Error (DWORD dwCommDlgExtendedError) noexcept |
Translates a Windows dialogue error code to the corresponding Windows system error code. More... | |
chsverror_t | Win32DlgErrorToChsvError (DWORD dwCommDlgExtendedError) noexcept |
Translates a Windows dialogue error code to the corresponding chsvlib error code. More... | |
The group provides support of basic error code processing mechanism further denoted as chsvlib error codes.
The chsvlib code is a 4 byte integer value defined by the CHSV_ERROR_CODE structure. This structure is built according to the Microsoft definition of the HRESULT.
There are three basic bit fields constituting an error code: the severity, the facility and the special code.
The severity is a one bit value specifying if the code is informational (when the bit is reset) or erroneous (when the bit is set). These two values are defined as follows:
Severity | Numeric value | Meaning |
---|---|---|
CHSV_SEVERITY_SUCCESS | 0 | Informational code |
CHSV_SEVERITY_ERROR | 1 | Error code |
The Facility is an eleven bit value specifying a group the code belongs to. Currently, only one group is defined for the chsvlib codes. Although, it is planned to expand the code set to include codes for specific mechanisms. These codes will be separated out into new facilities. To support forward compatibility the codes defined for mechanisms developed outside of the chsvlib code facilities should be defined with facility greater then 1200.
Facility | Numeric value | Meaning |
---|---|---|
CHSV_FACILITY_GENERAL | 1047 | General group of codes |
The special code is a 16 bit value that is unique within the facility it is defined.
Currently the following codes are defined:
Code definition | Severity | Facility | Special Code | Full numeric code | Description |
---|---|---|---|---|---|
CHSVERROR_SUCCESS | CHSV_SEVERITY_SUCCESS | 0 | 0 | 0x20000000 | Operation completed successfully |
CHSVERROR_SUCCESS_FALSE | CHSV_SEVERITY_SUCCESS | 0 | 1 | 0x20000001 | Operation completed successfully and returned false result (as opposed to CHSVERROR_SUCCESS) |
CHSVERROR_SUCCESS_CANCELLED | CHSV_SEVERITY_SUCCESS | CHSV_FACILITY_GENERAL | 15 | 0x2417000f | Operation was cancelled with success code |
CHSVERROR_OUTOFMEMORY | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 1 | 0xa4170001 | Out of memory |
CHSVERROR_INVALID_PARAMETER | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 2 | 0xa4170002 | Invalid parameter |
CHSVERROR_INSUFFICIENT_BUFFER | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 3 | 0xa4170003 | Insufficient buffer |
CHSVERROR_OUT_OF_RANGE | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 4 | 0xa4170004 | A value is out of valid range |
CHSVERROR_INITIALIZATION_FAILURE | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 5 | 0xa4170005 | Initialization failure |
CHSVERROR_NOT_INITIALIZED | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 6 | 0xa4170006 | Not initialized |
CHSVERROR_ALREADY_INITIALIZED | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 7 | 0xa4170007 | Already initialized |
CHSVERROR_INVALID_VERSION | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 8 | 0xa4170008 | Invalid version |
CHSVERROR_NOT_FOUND | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 9 | 0xa4170009 | Item is not found |
CHSVERROR_ALREADY_EXISTS | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 10 | 0xa417000a | Item already exists |
CHSVERROR_INVALID_RESOURCE | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 11 | 0xa417000b | Resource content or type is invalid |
CHSVERROR_ACCESS_DENIED | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 12 | 0xa417000c | Access is denied |
CHSVERROR_STORAGE_FULL | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 13 | 0xa417000d | The storage is full |
CHSVERROR_INVALID_CHAR_SEQUENCE | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 14 | 0xa417000e | A byte sequence is not a valid multi-byte character of the current code page |
CHSVERROR_OPERATION_CANCELLED | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 15 | 0xa417000f | The operation was cancelled |
CHSVERROR_NAME_TOO_LONG | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 16 | 0xa4170010 | A specified name is too long |
CHSVERROR_DEADLOCK | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 17 | 0xa4170011 | A deadlock is assumed |
CHSVERROR_TIMEOUT | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 18 | 0xa4170012 | Operation timed out |
CHSVERROR_OWNER_IS_DEAD | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 19 | 0xa4170013 | An owner of an object is dead |
CHSVERROR_NOT_SUPPORTED | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 20 | 0xa4170014 | Operation is not supported |
CHSVERROR_ARITHMETIC_OVERFLOW | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 21 | 0xa4170015 | An arithmetic overflow occurred |
CHSVERROR_STACK_OVERFLOW | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 22 | 0xa4170016 | A stack overflow occurred (too deep recursion?) |
CHSVERROR_PLATFORM_ERROR | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 256 | 0xa4170100 | Underlying platform error |
CHSVERROR_LOGIC_ERROR | CHSV_SEVERITY_ERROR | CHSV_FACILITY_GENERAL | 65535 | 0xa417ffff | Program logic error |
To define new codes use the ChsvCode macro.