Beispiel #1
0
OVRError::OVRError(ovrResult code, const char* pFormat, ...)
    : OVRError(code)
{
    va_list argList;
    va_start(argList, pFormat);
    StringBuffer strbuff;
    strbuff.AppendFormatV(pFormat, argList);
    SetDescription(strbuff.ToCStr());
    va_end(argList);
}
Beispiel #2
0
OVRError MakeError(ovrResult errorCode, ovrSysErrorCode sysCode, const char* pSourceFile,
                    int sourceLine, bool logError, bool assertError, const char* pContext, const char* pDescriptionFormat, ...)
{
    OVRError ovrError(errorCode);

    ovrError.SetCurrentValues(); // Sets the current time, etc.

    ovrError.SetSysCode(sysCode);

    va_list argList;
    va_start(argList, pDescriptionFormat);
    StringBuffer strbuff;
    strbuff.AppendFormatV(pDescriptionFormat, argList);
    va_end(argList);
    ovrError.SetDescription(strbuff.ToCStr());

    ovrError.SetContext(pContext);

    ovrError.SetSource(pSourceFile, sourceLine);

    // Set the TLS last error.
    LastErrorTLS::GetInstance()->LastError() = ovrError;

    int silencerOptions = ovrlog::ErrorSilencer::GetSilenceOptions();
    if (silencerOptions & ovrlog::ErrorSilencer::CompletelySilenceLogs)
    {
        logError = false;
    }
    if (silencerOptions & ovrlog::ErrorSilencer::PreventErrorAsserts)
    {
        assertError = false;
    }

    // If logging the error:
    if (logError)
    {
        Logger.LogError(ovrError.GetDescription().ToCStr());
    }

    // If asserting the error:
    if (assertError)
    {
        // Assert in debug mode to alert unit tester/developer of the error as it occurs.
        OVR_FAIL_M(ovrError.GetDescription().ToCStr());
    }

    if (ErrorCallback)
    {
        const bool quiet = !logError && !assertError;
        ErrorCallback(ovrError, quiet);
    }

    return ovrError;
}