mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 15:26:11 +01:00
Throw instead of calling exit in RegistrarForTagAliases constructor
Caries a problem vis-a-vis Windows, just like previous commit, but that can be fixed later on. Closes #866
This commit is contained in:
parent
f64d914bff
commit
4597b43912
@ -44,14 +44,20 @@ namespace Catch {
|
|||||||
|
|
||||||
if( !startsWith( alias, "[@" ) || !endsWith( alias, ']' ) ) {
|
if( !startsWith( alias, "[@" ) || !endsWith( alias, ']' ) ) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "error: tag alias, \"" << alias << "\" is not of the form [@alias name].\n" << lineInfo;
|
oss << Colour( Colour::Red )
|
||||||
|
<< "error: tag alias, \"" << alias << "\" is not of the form [@alias name].\n"
|
||||||
|
<< Colour( Colour::FileName )
|
||||||
|
<< lineInfo << '\n';
|
||||||
throw std::domain_error( oss.str().c_str() );
|
throw std::domain_error( oss.str().c_str() );
|
||||||
}
|
}
|
||||||
if( !m_registry.insert( std::make_pair( alias, TagAlias( tag, lineInfo ) ) ).second ) {
|
if( !m_registry.insert( std::make_pair( alias, TagAlias( tag, lineInfo ) ) ).second ) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "error: tag alias, \"" << alias << "\" already registered.\n"
|
oss << Colour( Colour::Red )
|
||||||
<< "\tFirst seen at " << find(alias)->lineInfo << '\n'
|
<< "error: tag alias, \"" << alias << "\" already registered.\n"
|
||||||
<< "\tRedefined at " << lineInfo;
|
<< "\tFirst seen at "
|
||||||
|
<< Colour( Colour::Red ) << find(alias)->lineInfo << '\n'
|
||||||
|
<< Colour( Colour::Red ) << "\tRedefined at "
|
||||||
|
<< Colour( Colour::FileName) << lineInfo << '\n';
|
||||||
throw std::domain_error( oss.str().c_str() );
|
throw std::domain_error( oss.str().c_str() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,14 +69,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RegistrarForTagAliases::RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ) {
|
RegistrarForTagAliases::RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ) {
|
||||||
try {
|
getMutableRegistryHub().registerTagAlias( alias, tag, lineInfo );
|
||||||
getMutableRegistryHub().registerTagAlias( alias, tag, lineInfo );
|
|
||||||
}
|
|
||||||
catch( std::exception& ex ) {
|
|
||||||
Colour colourGuard( Colour::Red );
|
|
||||||
Catch::cerr() << ex.what() << std::endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
Loading…
Reference in New Issue
Block a user