Function Session

Synopsis

#include <include/internal/catch_session.h>

Session()

Description

No description yet.

Source

Lines 143-173 in include/internal/catch_session.cpp. Line 22 in include/internal/catch_session.h.

Session::Session() {
    static bool alreadyInstantiated = false;
    if( alreadyInstantiated ) {
        CATCH_TRY { CATCH_INTERNAL_ERROR( "Only one instance of Catch::Session can ever be used" ); }
        CATCH_CATCH_ALL { getMutableRegistryHub().registerStartupException(); }
    }
    // There cannot be exceptions at startup in no-exception mode.
!defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
    const auto& exceptions = getRegistryHub().getStartupExceptionRegistry().getExceptions();
    if ( !exceptions.empty() ) {
        config();
        getCurrentMutableContext().setConfig(m_config);
        m_startupExceptions = true;
        Colour colourGuard( Colour::Red );
        Catch::cerr() << "Errors occurred during startup!" << '\n';
        // iterate over all exceptions and notify user
        for ( const auto& ex_ptr : exceptions ) {
            try {
                std::rethrow_exception(ex_ptr);
            } catch ( std::exception const& ex ) {
                Catch::cerr() << Column( ex.what() ).indent(2) << '\n';
            }
        }
    }
if
    alreadyInstantiated = true;
    m_cli = makeCommandLineParser( m_configData );
}





Add Discussion as Guest

Log in