#include "twitchsdk/core/types/coretypes.h"
#include "twitchsdk/core/assertion.h"
#include <functional>
#include <vector>
Go to the source code of this file.
|
| | ttv |
| | JSON (JavaScript Object Notation).
|
| |
|
| #define | CONSTRUCT_ERROR_ID_VALUE(MODULE_ID, ERROR_ID) ( (1U << 31) | ( (MODULE_ID & kErrorModuleIdMask) << 16) | (ERROR_ID & kErrorIdMask) ) |
| |
| #define | CONSTRUCT_WARNING_ID_VALUE(MODULE_ID, ERROR_ID) ( (0U << 31) | ( (MODULE_ID & kErrorModuleIdMask) << 16) | (ERROR_ID & kErrorIdMask) ) |
| |
| #define | GET_MODULE_ID(ec) ( (ec >> 16) & kErrorModuleIdMask ) |
| |
| #define | GET_ERROR_ID(ec) ( ec & kErrorIdMask ) |
| |
| #define | TTV_CORE_ERROR_IDS |
| |
| #define | USE_TTV_ERROR_ID(ec) ec, |
| |
| #define | USE_TTV_WARNING_ID(ec) ec, |
| |
| #define | USE_TTV_SUCCESS_ID(ec) ec = 0, |
| |
| #define | BEGIN_WARNING_IDS(ec) ec = CONSTRUCT_WARNING_ID_VALUE(TTV_MODULE_ID_TWITCH_CORE, (1 << 12)), |
| |
| #define | END_WARNING_IDS(ec) ec, |
| |
| #define | BEGIN_ERROR_IDS(ec) ec = CONSTRUCT_ERROR_ID_VALUE(TTV_MODULE_ID_TWITCH_CORE, 1), |
| |
| #define | END_ERROR_IDS(ec) ec |
| |
| #define | TTV_SUCCEEDED(ec) ( (ec & kErrorFlagMask) == 0 ) |
| |
| #define | TTV_FAILED(ec) ( (ec & kErrorFlagMask) != 0 ) |
| |
| #define | ASSERT_ON_ERROR(ec) { assert ( TTV_SUCCEEDED(ec) ); } |
| |
| #define | RETURN_CLIENT_ERROR(ec) { return ec; } |
| |
| #define | TTV_RETURN_ON_NULL(ptr, ec) { if ( (ptr) == nullptr) RETURN_CLIENT_ERROR(ec); } |
| |
| #define | TTV_RETURN_ON_NOT_NULL(ptr, ec) { if ( (ptr) != nullptr) RETURN_CLIENT_ERROR(ec); } |
| |
| #define | TTV_RETURN_ON_EMPTY_STRING(str, ec) { if (str == nullptr || str[0] == '\0') RETURN_CLIENT_ERROR(ec); } |
| |
| #define | TTV_RETURN_ON_EMPTY_STDSTRING(str, ec) { if (str.size() == 0) RETURN_CLIENT_ERROR(ec); } |
| |
| #define | TTV_RETURN_ON_ERROR(err) { if (TTV_FAILED(ec)) RETURN_CLIENT_ERROR(ec); } |
| |
| #define | TTV_RETURN_ON_DIFFERENT(a, b, ec) { if ( (a) != (b) ) RETURN_CLIENT_ERROR(ec); } |
| |
| #define | TTV_RETURN_ON_SAME(a, b, ec) { if ( (a) == (b) ) RETURN_CLIENT_ERROR(ec); } |
| |
◆ ASSERT_ON_ERROR
◆ BEGIN_ERROR_IDS
◆ BEGIN_WARNING_IDS
◆ CONSTRUCT_ERROR_ID_VALUE
| #define CONSTRUCT_ERROR_ID_VALUE |
( |
|
MODULE_ID, |
|
|
|
ERROR_ID |
|
) |
| ( (1U << 31) | ( (MODULE_ID & kErrorModuleIdMask) << 16) | (ERROR_ID & kErrorIdMask) ) |
Creates an error code integer conforming to the format of TTV_ErrorCode.
◆ CONSTRUCT_WARNING_ID_VALUE
| #define CONSTRUCT_WARNING_ID_VALUE |
( |
|
MODULE_ID, |
|
|
|
ERROR_ID |
|
) |
| ( (0U << 31) | ( (MODULE_ID & kErrorModuleIdMask) << 16) | (ERROR_ID & kErrorIdMask) ) |
Creates an warning code integer conforming to the format of TTV_ErrorCode.
◆ END_ERROR_IDS
| #define END_ERROR_IDS |
( |
|
ec | ) |
ec |
◆ END_WARNING_IDS
| #define END_WARNING_IDS |
( |
|
ec | ) |
ec, |
◆ GET_ERROR_ID
Extracts the error id from the given TTV_ErrorCode. It is appropriate to cast the id to the module-specific enumeration value.
◆ GET_MODULE_ID
Extracts the module id from the given TTV_ErrorCode.
◆ RETURN_CLIENT_ERROR
| #define RETURN_CLIENT_ERROR |
( |
|
ec | ) |
{ return ec; } |
◆ TTV_CORE_ERROR_IDS
| #define TTV_CORE_ERROR_IDS |
◆ TTV_FAILED
Determines if the given code has the error bit set.
◆ TTV_RETURN_ON_DIFFERENT
◆ TTV_RETURN_ON_EMPTY_STDSTRING
| #define TTV_RETURN_ON_EMPTY_STDSTRING |
( |
|
str, |
|
|
|
ec |
|
) |
| { if (str.size() == 0) RETURN_CLIENT_ERROR(ec); } |
◆ TTV_RETURN_ON_EMPTY_STRING
| #define TTV_RETURN_ON_EMPTY_STRING |
( |
|
str, |
|
|
|
ec |
|
) |
| { if (str == nullptr || str[0] == '\0') RETURN_CLIENT_ERROR(ec); } |
◆ TTV_RETURN_ON_ERROR
◆ TTV_RETURN_ON_NOT_NULL
◆ TTV_RETURN_ON_NULL
◆ TTV_RETURN_ON_SAME
◆ TTV_SUCCEEDED
Determines if the given code does not have the error bit set. Pure success and warnings will pass this check.
◆ USE_TTV_ERROR_ID
| #define USE_TTV_ERROR_ID |
( |
|
ec | ) |
ec, |
◆ USE_TTV_SUCCESS_ID
| #define USE_TTV_SUCCESS_ID |
( |
|
ec | ) |
ec = 0, |
◆ USE_TTV_WARNING_ID
| #define USE_TTV_WARNING_ID |
( |
|
ec | ) |
ec, |
◆ TTV_ErrorCode
The generic error code type which represents error codes from all modules. It is constructed piecemeal as follows:
Error bit(1) | ModuleId(15) | ErrorId(16)
- Error: A flag bit which indicates whether or not the value is an error. If 1, it is an error. If 0, it is a warning and TTV_SUCCEEDED(ec) will be true.
- ModuleId: 15 bits to represent the module the code is defined in. This is not necessarily the source of the error. Each module has a unique id.
- ErrorId: 16 bits to represent the unique error code within the module. Each module generally has an enumeration which defines them without the flag or module id.
◆ TTV_CoreErrorId
TTV_CoreErrorId - The error codes defined in core.
| Enumerator |
|---|
| TTV_CORE_ERROR_IDS | |
◆ kErrorFlagMask
| const uint32_t kErrorFlagMask = 0x80000000 |
◆ kErrorIdMask
| const uint32_t kErrorIdMask = 0xFFFF |
◆ kErrorModuleIdMask
| const uint32_t kErrorModuleIdMask = 0x7FFF |
◆ TTV_MODULE_ID_TWITCH_CORE
| const uint32_t TTV_MODULE_ID_TWITCH_CORE = 0 |
The unique module identifier for core.