Skip to content

sdk/rterror.h

Namespaces

Name
cvedia
cvedia::rt
API for controlling the server and lifecycle management of runtime instances.
std

Classes

Name
struct RTErrCategory

Types

Name
enum class RTErrc
template <class T >
using tl::expected< T, std::error_code >
expected
using tl::unexpected< std::error_code > unexpected

Functions

Name
attribute((visibility("default")) ) const
std::error_code make_error_code(RTErrc e)

Defines

Name
CHECK_LUA(obj)
CHECK_NULLPTR(ptr)
CHECK_RET(var)
CHECK_IGN(var)
CHECK_VAL(var, val)
TRY(var)
TRY_ERRC(var)
TRY_VAL(var, val)
COPY_VAL_IF_SET(var, val)
TRY_LUA(var)
TRY_VAL_LUA(var, val)
TRY_LUA_CONT(var)
RT_LUA_TRY(var, expr)
RT_LUA_CATCH(expr)
RT_ASSERT(expr, message)
RT_TRY(var, expr)
RT_TRY_REASON(var, expr, err)
RT_TRY_WARNING(var, expr, message)
RT_TRY_ERROR(var, expr, message)
RT_TRY_DEBUG(var, expr, message)
RT_TRY2(var, expr)
RT_CATCH(expr)
RT_CATCH_WARNING(expr, message)
RT_CATCH_ERROR(expr, message)
RT_CATCH_CUDA_ERROR(expr, message)
RT_CATCH_DEBUG(expr, message)
RT_CHECK_BUFFER_DATATYPE_INITIALIZED()
RT_CHECK_BUFFER_DATATYPE_INITIALIZED_VOID()
RT_IF(var, expr)
RT_CATCH_REST(expr, errc, errm)
RT_TRY_REST(var, expr, errc, errm)
RT_CATCH_REST_MAP(expr, errcMap, errMsgMap, defHttpCode)
RT_TRY_REST_MAP(var, expr, errcMap, errMsgMap, defCode)

Types Documentation

enum RTErrc

Enumerator Value Description
Success 0
AlreadyExists
AlreadyInitialized
AuthorizationRequired
BufferTooSmall
ConfigIsExternal
ConnectionError
ConnectionRefused
DeviceInitFailed
DataNotNeeded
Discarded
DoesNotExist
Empty
EndOfFile
FailedInitBackend
FailedToCreate
FailedToDownload
FileAlreadyExists
FileCannotBeOpened
FileNotFound
InferenceTimedOut
InstanceAlreadyLoaded
InstanceNotLoaded
InstanceNotRunning
InvalidArgument
InvalidChecksum
InvalidConfig
InvalidPath
InvalidThread
IsDisabled
IsRunning
KeyNotFound
LabelNotEnforced
LayerNotFound
LicenseActivationError
LicenseAlreadyExists
LicenseDataRetrievalError
LicenseDeactivationError
LicenseDecodeError
LicenseDecryptionError
LicenseDoesNotExists
LicenseEncryptionError
LicenseFileCannotBeLoaded
LicenseFileCannotBeSaved
LicenseFingerprintMismatch
LicenseIsInvalid
LicenseKeyFormatIsInvalid
LicenseMachineLimitExceeded
LicenseMetaFileDoesNotExist
LicenseProductMismatch
LicenseParseError
LicenseSchemaError
LoadModelFailed
MaxNumberOfStreamsReached
MaxRunningInstancesLimitReached
MinIntervalNotElapsed
MissingData
ModelNotLoaded
NetworkError
NoClassificationOutput
NoFrameToRead
NoLicensesFound
NoLicensesLoaded
NoOcrOutput
NoServerAvailable
NoSuchBackend
NoSuchDevice
NotEnforced
NotEnoughData
NotImplemented
NotInitialized
OperationFailed
OutOfRange
ParseError
PluginFailed
PluginMissing
QoSDropped
QueueFull
RateLimited
ReachedDailyLimit
ReachedHourlyLimit
ReadFailed
ReadOnly
SchemaError
ShuttingDown
SolutionNotFound
SolutionNotSet
Unauthorized
UnknownError
UnknownExtension
UnknownThread
UnregisteredObjectInUse
UnsupportedCodec
UnsupportedEvent
UnsupportedModel
UnsupportedOperation
ModelValidationError
RegistryKeyNotFound
RegistryDegraded
RegistryDecryptFailed
QueryCancelled
QueryTimedOut

using expected

template <class T >
using expected =  tl::expected<T, std::error_code>;

using unexpected

using unexpected =  tl::unexpected<std::error_code>;

Functions Documentation

function attribute

__attribute__(
    (visibility("default")) 
) const

function make_error_code

inline std::error_code make_error_code(
    RTErrc e
)

Macros Documentation

define CHECK_LUA

#define CHECK_LUA(
    obj
)
do {if ((obj) == nullptr) {LOGE << "Invalid Lua object passed (nullptr)"; luaL_error(s, "%s", "Invalid Lua object passed");}} while(0)

define CHECK_NULLPTR

#define CHECK_NULLPTR(
    ptr
)
do {if ((ptr) == nullptr){std::string msg = std::string("Object is not initialized: ") + std::string(#ptr); luaL_error(s, "%s", msg.c_str()); }} while(0)

define CHECK_RET

#define CHECK_RET(
    var
)
do {auto &&tmp = var; if (!tmp) {std::cout << "Function call returned: " + tmp.error().message(); return -1;}} while(0)

define CHECK_IGN

#define CHECK_IGN(
    var
)
do {auto &&tmp = var; if (!tmp) {std::cout << "Function call returned: " + tmp.error().message();}} while(0)

define CHECK_VAL

#define CHECK_VAL(
    var,
    val
)
do {auto &&tmp = var; if (!tmp) {std::cout << "Function call returned: " + tmp.error().message(); return -1;} else { (val) = std::move(tmp.value());}} while(0)

define TRY

#define TRY(
    var
)
do {auto &&tmp = var; if (!tmp) return ::cvedia::rt::unexpected(tmp.error());} while(0)

define TRY_ERRC

#define TRY_ERRC(
    var
)
do {auto &&errc = var; if (!errc) return errc;} while(0)

define TRY_VAL

#define TRY_VAL(
    var,
    val
)
do {auto &&tmp = var; if (!tmp) return cvedia::rt::unexpected(tmp.error()); (val) = std::move(tmp.value());} while(0)

define COPY_VAL_IF_SET

#define COPY_VAL_IF_SET(
    var,
    val
)
do {auto &&tmp = var; if (tmp) {(val) = std::move(tmp.value());}} while(0)

define TRY_LUA

#define TRY_LUA(
    var
)
do {auto &&tmp = var; if (!tmp) { std::string msg = "Function call returned: " + tmp.error().message(); luaL_error(s, "%s", msg.c_str());}} while(0)

define TRY_VAL_LUA

#define TRY_VAL_LUA(
    var,
    val
)
do {auto &&tmp = var; if (!tmp) { std::string msg = "Function call returned: " + tmp.error().message(); luaL_error(s, "%s", msg.c_str());} (val) = std::move(tmp.value());} while(0)

define TRY_LUA_CONT

#define TRY_LUA_CONT(
    var
)
do {auto &&tmp = var; if (!tmp) { std::string msg = "Function returned: " + tmp.error().message();}} while(0)

define RT_LUA_TRY

#define RT_LUA_TRY(
    var,
    expr
)
    auto &&UNIQUE_NAME(tmp) = expr; \
    if (!UNIQUE_NAME(tmp)) { \
        std::string msg = "Function call returned: " + UNIQUE_NAME(tmp).error().message(); \
        luaL_error(s, "%s", msg.c_str()); \
    } \
    var = std::move(UNIQUE_NAME(tmp).value())

define RT_LUA_CATCH

#define RT_LUA_CATCH(
    expr
)
    auto &&UNIQUE_NAME(tmp) = expr; \
    if (!UNIQUE_NAME(tmp)) { \
        std::string msg = "Function call returned: " + UNIQUE_NAME(tmp).error().message(); \
        luaL_error(s, "%s", msg.c_str()); \
    }

define RT_ASSERT

#define RT_ASSERT(
    expr,
    message
)
    if (!(expr)) { \
        LOGE << message; \
        return ::cvedia::rt::unexpected(RTErrc::InvalidArgument); \
    }

define RT_TRY

#define RT_TRY(
    var,
    expr
)
    auto &&UNIQUE_NAME(tmp) = expr; \
    if (!UNIQUE_NAME(tmp)) { \
        return ::cvedia::rt::unexpected(UNIQUE_NAME(tmp).error()); \
    } \
    var = std::move(UNIQUE_NAME(tmp).value())

define RT_TRY_REASON

#define RT_TRY_REASON(
    var,
    expr,
    err
)
    auto &&UNIQUE_NAME(tmp) = expr; \
    if (!UNIQUE_NAME(tmp)) { \
        return ::cvedia::rt::unexpected(err); \
    } \
    var = std::move(UNIQUE_NAME(tmp).value())

define RT_TRY_WARNING

#define RT_TRY_WARNING(
    var,
    expr,
    message
)
    auto &&UNIQUE_NAME(tmp) = expr; \
    if (!UNIQUE_NAME(tmp)) { \
        LOGW << message; \
        return ::cvedia::rt::unexpected(UNIQUE_NAME(tmp).error()); \
    } \
    var = std::move(UNIQUE_NAME(tmp).value())

define RT_TRY_ERROR

#define RT_TRY_ERROR(
    var,
    expr,
    message
)
    auto &&UNIQUE_NAME(tmp) = expr; \
    if (!UNIQUE_NAME(tmp)) { \
        LOGE << message; \
        return ::cvedia::rt::unexpected(UNIQUE_NAME(tmp).error()); \
    } \
    var = std::move(UNIQUE_NAME(tmp).value())

define RT_TRY_DEBUG

#define RT_TRY_DEBUG(
    var,
    expr,
    message
)
    auto &&UNIQUE_NAME(tmp) = expr; \
    if (!UNIQUE_NAME(tmp)) { \
        LOGD << message; \
        return ::cvedia::rt::unexpected(UNIQUE_NAME(tmp).error()); \
    } \
    var = std::move(UNIQUE_NAME(tmp).value())

define RT_TRY2

#define RT_TRY2(
    var,
    expr
)
    auto &&UNIQUE_NAME(tmp2) = expr; \
    if (!UNIQUE_NAME(tmp2)) { \
        return ::cvedia::rt::unexpected(UNIQUE_NAME(tmp2).error()); \
    } \
    var = std::move(UNIQUE_NAME(tmp2).value())

define RT_CATCH

#define RT_CATCH(
    expr
)
    auto &&UNIQUE_NAME(tmp) = expr; \
    if (!UNIQUE_NAME(tmp)) \
        return ::cvedia::rt::unexpected(UNIQUE_NAME(tmp).error())

define RT_CATCH_WARNING

#define RT_CATCH_WARNING(
    expr,
    message
)
    auto &&UNIQUE_NAME(tmp) = expr; \
    if (!UNIQUE_NAME(tmp)) { \
        LOGW << message; \
        return ::cvedia::rt::unexpected(UNIQUE_NAME(tmp).error()); \
    }

define RT_CATCH_ERROR

#define RT_CATCH_ERROR(
    expr,
    message
)
    auto &&UNIQUE_NAME(tmp) = expr; \
    if (!UNIQUE_NAME(tmp)) { \
        LOGE << message; \
        return ::cvedia::rt::unexpected(UNIQUE_NAME(tmp).error()); \
    }

define RT_CATCH_CUDA_ERROR

#define RT_CATCH_CUDA_ERROR(
    expr,
    message
)
    auto &&UNIQUE_NAME(tmp) = expr; \
    if (UNIQUE_NAME(tmp) != cudaSuccess) { \
        LOGE << message; \
        return ::cvedia::rt::unexpected(RTErrc::OperationFailed); \
    }

define RT_CATCH_DEBUG

#define RT_CATCH_DEBUG(
    expr,
    message
)
    auto &&UNIQUE_NAME(tmp) = expr; \
    if (!UNIQUE_NAME(tmp)) { \
        LOGD << message; \
        return ::cvedia::rt::unexpected(UNIQUE_NAME(tmp).error()); \
    }

define RT_CHECK_BUFFER_DATATYPE_INITIALIZED

#define RT_CHECK_BUFFER_DATATYPE_INITIALIZED(

)
    if (dataType() == BufferDataType::UNKNOWN) { \
        PLOGE_(LogBuffer) << "Buffer has UNKNOWN data type - operation requires initialized buffer"; \
        return ::cvedia::rt::unexpected(RTErrc::InvalidArgument); \
    }

define RT_CHECK_BUFFER_DATATYPE_INITIALIZED_VOID

#define RT_CHECK_BUFFER_DATATYPE_INITIALIZED_VOID(

)
    if (dataType() == BufferDataType::UNKNOWN) { \
        PLOGE_(LogBuffer) << "Buffer has UNKNOWN data type - operation requires initialized buffer"; \
        return; \
    }

define RT_IF

#define RT_IF(
    var,
    expr
)
    auto &&UNIQUE_NAME(tmp) = expr; \
    if (!UNIQUE_NAME(tmp)) { \
    } else { var = std::move(UNIQUE_NAME(tmp).value());

define RT_CATCH_REST

#define RT_CATCH_REST(
    expr,
    errc,
    errm
)
    auto &&UNIQUE_NAME(tmp) = expr; \
    if (!UNIQUE_NAME(tmp)) { \
        response.status = static_cast<int>(errc); \
        response.set_content(errm, "text/plain"); \
        return; \
    }

define RT_TRY_REST

#define RT_TRY_REST(
    var,
    expr,
    errc,
    errm
)
    RT_CATCH_REST(expr, errc, errm) \
    var = std::move(UNIQUE_NAME(tmp).value())

define RT_CATCH_REST_MAP

#define RT_CATCH_REST_MAP(
    expr,
    errcMap,
    errMsgMap,
    defHttpCode
)
    auto &&UNIQUE_NAME(tmp) = expr; \
    auto _errc = defHttpCode; \
    std::string _errMsg; \
    if (!UNIQUE_NAME(tmp)) { \
        if (errcMap.find(UNIQUE_NAME(tmp).error()) != errcMap.cend()) { \
            _errc = errcMap.at(UNIQUE_NAME(tmp).error()); \
        } \
        if (errMsgMap.find(_errc) != errMsgMap.cend()) { \
            _errMsg = errMsgMap.at(_errc); \
        } \
        response.status = static_cast<int>(_errc); \
        response.set_content(_errMsg, "text/plain"); \
        return; \
    }

define RT_TRY_REST_MAP

#define RT_TRY_REST_MAP(
    var,
    expr,
    errcMap,
    errMsgMap,
    defCode
)
    RT_CATCH_REST_MAP(expr, errcMap, errMsgMap, defCode) \
    var = std::move(UNIQUE_NAME(tmp).value())