exception translators considered even for types deriving from std::exception, now

- also added docs for exception translators
- updated approvals
This commit is contained in:
Phil Nash 2015-11-18 08:39:21 +00:00
parent ed6e9128a4
commit a49f088032
8 changed files with 101 additions and 28 deletions

View file

@ -32,13 +32,13 @@ namespace Catch {
#ifdef __OBJC__
// In Objective-C try objective-c exceptions first
@try {
throw;
return tryTranslators();
}
@catch (NSException *exception) {
return Catch::toString( [exception description] );
}
#else
throw;
return tryTranslators();
#endif
}
catch( TestFailureException& ) {
@ -54,20 +54,15 @@ namespace Catch {
return msg;
}
catch(...) {
return tryTranslators( m_translators.begin() );
return "Unknown exception";
}
}
std::string tryTranslators( std::vector<const IExceptionTranslator*>::const_iterator it ) const {
if( it == m_translators.end() )
return "Unknown exception";
try {
return (*it)->translate();
}
catch(...) {
return tryTranslators( it+1 );
}
std::string tryTranslators() const {
if( m_translators.empty() )
throw;
else
return m_translators[0]->translate( m_translators.begin()+1, m_translators.end() );
}
private: