Esempio n. 1
0
void CCgiContext::CheckStatus(void) const
{
    if (m_StatusCode == CCgiException::eStatusNotSet) return;

    NCBI_EXCEPTION_VAR(ex, CCgiException, eUnknown,
        m_StatusMessage);
    ex.SetStatus(m_StatusCode);
    NCBI_EXCEPTION_THROW(ex);
}
Esempio n. 2
0
void CObject::ThrowNullPointerException(void)
{
    if ( sx_abort_on_null ) {
        Abort();
    }
    NCBI_EXCEPTION_VAR(ex,
        CCoreException, eNullPtr, "Attempt to access NULL pointer.");
    ex.SetSeverity(eDiag_Critical);
    NCBI_EXCEPTION_THROW(ex);
}
Esempio n. 3
0
void CObject::ThrowNullPointerException(const type_info& type)
{
    if ( sx_abort_on_null ) {
        Abort();
    }
    NCBI_EXCEPTION_VAR(ex,
                       CCoreException, eNullPtr,
                       string("Attempt to access NULL pointer: ")+type.name());
    ex.SetSeverity(eDiag_Critical);
    NCBI_EXCEPTION_THROW(ex);
}
Esempio n. 4
0
void CTestDiagApp::x_PrintMessages(int         test_number,
                                   int         idx,
                                   const char* module,
                                   const char* nclass,
                                   const char* function)
{
    string location  = string(module) + "::" + nclass + "::" +
                       function + "()";
    string postmsg   = location + " in ERR_POST";
    string exceptmsg = location + " in the one level exception";
    string secondmsg = location + " in the two levels exception";

    if (idx == 0) {
        m_Messages[ TCase( test_number, 0 ) ] = postmsg;
        m_Messages[ TCase( test_number, 1 ) ] = exceptmsg;
        m_Messages[ TCase( test_number, 2 ) ] = secondmsg;
    }

    // ERR_POST
    ERR_POST(x_MakeMessage(postmsg, idx, TCase(test_number,0))
             << MDiagModule(module)
             << MDiagClass(nclass)
             << MDiagFunction(function));

    // one level exception
    try {
        NCBI_EXCEPTION_VAR(expt, CException, eUnknown, "exception");
        expt.SetModule(module);
        expt.SetClass(nclass);
        expt.SetFunction(function);
        NCBI_EXCEPTION_THROW(expt);
    }
    catch (const  CException& ex) {
        NCBI_REPORT_EXCEPTION(x_MakeMessage(exceptmsg,
                                            idx,
                                            TCase(test_number, 1)), ex);
    }


#if defined(NCBI_COMPILER_WORKSHOP)
# if NCBI_COMPILER_VERSION == 530 || NCBI_COMPILER_VERSION == 550
    // Workshop 5.3 and 5.5 have MT-unsafe throw. To avoid test failures
    // use mutex.
    DEFINE_STATIC_FAST_MUTEX(s_ThrowMutex);
    CFastMutexGuard guard(s_ThrowMutex);
# endif
#endif


    // two level exceptions
    try {
        try {
            NCBI_EXCEPTION_VAR(expt, CException, eUnknown, "exception1");
            expt.SetModule(module);
            expt.SetClass(nclass);
            expt.SetFunction(function);
            NCBI_EXCEPTION_THROW(expt);
        }
        catch (const  CException& ex) {
            NCBI_EXCEPTION_VAR_EX(e2, &ex, CException, eUnknown, "exception2");
            e2.SetModule(module);
            e2.SetClass(nclass);
            e2.SetFunction(function);
            NCBI_EXCEPTION_THROW(e2);
        }
    }
    catch (const  CException& ex) {
        NCBI_REPORT_EXCEPTION(x_MakeMessage(secondmsg,
                                            idx,
                                            TCase(test_number, 2)), ex);
    }
}